-
Nov 7th, 2017, 04:20 PM
#1
Thread Starter
Member
[RESOLVED] angularjs help, pulling hair out, and i dont have much
I got this off the interwebs, was mucking about trying to figure out how to do a few things, mostly straight forward, (or should be). I've obviously missed something, and i modified the GetProductList to use EF instead of straight ADO code, it hits the return list; with the proper (well what i asked for anyway) list of staff.
Questions, Comments and/or scathing indictments always welcome.
Can anyone spot what is not correct with this? i have banged my head for 6 hours on what should have been a simple thing.
Default.aspx
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="NetAccessToy.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript">
angular.module('drpdwnApp', []).controller('drpdwnCtrl', function ($scope, $http) {
$scope.ProductList = null;
//Declaring the function to load data from database
$scope.fillProductList = function () {
$http({
method: 'POST',
url: 'Default.aspx/GetProductList',
data: {}
}).success(function (result) {
$scope.ProductList = result.d;
});
};
//Calling the function to load the data on pageload
$scope.fillProductList();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div ng-app="drpdwnApp" ng-controller="drpdwnCtrl">
<select ng-model="drpdpwnvalue" ng-options="item.ID for item in ProductList">
<option value="" label="Select an item"></option>
</select>
</div>
</form>
</body>
</html>
backing code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NetAccessToy.Models;
namespace NetAccessToy
{
public partial class Default : System.Web.UI.Page
{
[System.Web.Services.WebMethod()]
public static List<StaffList> GetProductList()
{
var db1 = new HRTraining2Entities();
List<StaffList> list = new List<StaffList>();
StaffList lsl;
var lst = new List<STAFF>();
lst = (from y in db1.STAFFs select y).ToList();
foreach (var x in lst)
{
lsl = new StaffList
{
id = x.staff_ID,
name = x.STAFF_LAST_NAME + " , " + x.STAFF_FIRST_NAME
};
list.Add(lsl);
}
return list;
}
}
public class StaffList
{
public int id { get; set; }
public string name { get; set; }
public StaffList(int ID, string NAME)
{
id = ID;
name = NAME;
}
public StaffList()
{
}
}
}
-
Nov 8th, 2017, 03:11 AM
#2
Re: angularjs help, pulling hair out, and i dont have much
Can anyone spot what is not correct with this?
Is the issue related to records not loading to the dropdown? Can you be more specific?
- kgc
-
Nov 8th, 2017, 07:39 AM
#3
Thread Starter
Member
Re: angularjs help, pulling hair out, and i dont have much
first, thank you for not raking me over the coals.
the app hits the breakpoint i set at the API return area, the list in VS looks good (its kinda long but that shouldnt' matter) but does not seem to hit the success function in the main page. I'm just learning angular, found this on line and with the exception of changing it from ADO to EF for the data in the API i made no other changes (well i did modify the class to fit).
no errors thrown, just does not populate the select as anticipated except with the initial option. I could do this in win forms in a matter of minutes but that was not what i was tasked with.
second place is just the first loser...
-
Nov 8th, 2017, 09:05 AM
#4
Thread Starter
Member
Re: angularjs help, pulling hair out, and i dont have much
fiddler is showing a 500 error, its running IIS express, so not sure how to find out what setting is hosed.
second place is just the first loser...
-
Nov 8th, 2017, 11:04 AM
#5
Thread Starter
Member
Re: [RESOLVED] angularjs help, pulling hair out, and i dont have much
was overwhelming the select, a couple of web config changes later, and its all good (that and reducing the number of rows.)
second place is just the first loser...
-
Nov 8th, 2017, 11:08 AM
#6
Re: [RESOLVED] angularjs help, pulling hair out, and i dont have much
so it turned out to be changes in web.config settings was the solution.
- kgc
-
Nov 8th, 2017, 11:12 AM
#7
Thread Starter
Member
Re: [RESOLVED] angularjs help, pulling hair out, and i dont have much
Originally Posted by KGComputers
so it turned out to be changes in web.config settings was the solution.
- kgc
I also moved the code out to a asmx file at the suggestion of a friend who does angular regularly. This was just me figuring things out and teaching an old dog a new trick, at 1000 rows it worked, at 4700 it stopped, so we added a key value to the web config <add key ="aspnet:MaxJsonDeserializerMembers" value="1500000000"/> and <httpRuntime targetFramework="4.5" maxRequestLength="20000" /> and now it loads even with the 4700 rows (albeit slowly), with the 1075 or so people we actually have its much better.
second place is just the first loser...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|