dcsimg
Results 1 to 7 of 7

Thread: [RESOLVED] angularjs help, pulling hair out, and i dont have much

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2001
    Location
    VA, USA
    Posts
    36

    Resolved [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()
            {
                
            }
        }
    }

  2. #2
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,944

    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
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 2001
    Location
    VA, USA
    Posts
    36

    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...

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2001
    Location
    VA, USA
    Posts
    36

    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...

  5. #5

    Thread Starter
    Member
    Join Date
    Oct 2001
    Location
    VA, USA
    Posts
    36

    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...

  6. #6
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,944

    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
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2001
    Location
    VA, USA
    Posts
    36

    Re: [RESOLVED] angularjs help, pulling hair out, and i dont have much

    Quote Originally Posted by KGComputers View Post
    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
  •  



Featured


Click Here to Expand Forum to Full Width