Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am having following errors in the ASP.net page . I am using a plugin called jTable( Reference jTable.org). This plugin is used to bind JSON with the HTML UI.

enter image description here

I am using following model

[DataContract]
    public class UserGroup
    {
        public UserGroup()
        {
            GroupId = 0;
        }

        #region Properties

        public short GroupId { get; set; }

        [DataMember]
        public string GroupCode { get; set; }

        [DataMember]
        public char GroupType {get;set;}

        [DataMember]
        public string GroupDescription { get; set; }
        #endregion
    }

Here is the ASPX code

<%@ Page Title="" AutoEventWireup="false" ViewStateMode="Disabled" Language="C#" MasterPageFile="~/Admin/Admin.Master"  CodeBehind="Groups.aspx.cs" 
Inherits="ERP.WebApp.Admin.Groups" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Content/themes/redmond/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
    <!-- jTable style file -->

    <link href="/Scripts/jtable/themes/standard/blue/jtable_blue.css" rel="stylesheet" type="text/css" />

    <script src="/Scripts/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
    <script src="/Scripts/modernizr-1.7.min.js" type="text/javascript"></script>
    <script src="/Scripts/jtablesite.js" type="text/javascript"></script>

    <!-- A helper library for JSON serialization -->
    <script type="text/javascript" src="/Scripts/jtable/external/json2.min.js"></script>
    <!-- Core jTable script file -->
    <script type="text/javascript" src="/Scripts/jtable/jquery.jtable.min.js"></script>
    <!-- ASP.NET Web Forms extension for jTable -->
    <script type="text/javascript" src="/Scripts/jtable/extensions/jquery.jtable.aspnetpagemethods.min.js"></script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<br /><br />
<div style="width:70%;margin:auto;height:500px">
<div id="GroupTableContainer"></div>
</div>
 <script type="text/javascript">

     $(document).ready(function () {

         //Prepare jtable plugin
         $('#GroupTableContainer').jtable({
             title: 'List of User Groups',
             paging: true, //Enables paging
             pageSize: 10, //Actually this is not needed since default value is 10.
             sorting: true, //Enables sorting
             defaultSorting: 'GroupCode ASC', //Optional. Default sorting on first load.
             actions: {
                 listAction: '/Admin/Groups.aspx/GroupsList',
                 createAction: '/Admin/Groups.aspx/CreateGroup',
                 updateAction: '/Admin/Groups.aspx/UpdateGroup',
                 deleteAction: '/Admin/Groups.aspx/DeleteGroup'
             },
             fields: {
                 GroupId: {
                     key: true,
                     create: false,
                     edit: false,
                     list: false                     
                 },
                 GroupCode: {
                     title: 'Group Code',
                     width: '15%'
                 },
                 GroupType: {
                     title: 'Group Type',
                     width: '25%',
                     options: { 'S': 'Student', 'F': 'Faculty', 'A': 'Accounts', 'M': 'Management', 'B': 'Library Staff', 'L': 'Lab Staff', 'E': 'E.R.P. Admins','T':'Training & Placement' }
                 },
                 GroupDescription: {
                     title: 'About the Group',
                     type: 'textarea',
                     width: '50%'
                 }
             }
         });

         //Load Groups list from server
         $('#GroupTableContainer').jtable('load');
     });

</script>
<br /><br />
</asp:Content>

And here is the ASPx.cs code that I am using

[WebMethod(EnableSession = true)]
        public static object GroupsList(int jtStartIndex = 0, int jtPageSize = 10, string jtSorting = null)
        {
            try
            {
                short pTotalRows = 0;
                List<UserGroup> groupList = new GroupsBL().GetAllUserGroups(out pTotalRows,(short)jtStartIndex,(byte) jtPageSize, jtSorting);

                //Return result to jTable
                return new { Result = "OK", Records = groupList, TotalRecordCount = pTotalRows };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }

        [WebMethod(EnableSession = true)]
        public static object CreateGroup(UserGroup pUserGroup)
        {
            try
            {
                var addedStudent = new GroupsBL().AddUserGroup(pUserGroup);
                if (addedStudent == true)
                    return new { Result = "OK"};
                else
                    return new { Result = "ERROR", Message = "Group Already Exists" };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }

        [WebMethod(EnableSession = true)]
        public static object UpdateGroup(UserGroup pUserGroup)
        {
            try
            {
                var updatedstudent = new GroupsBL().UpdateUserGroup(pUserGroup);
                if (updatedstudent == true)
                    return new { result = "ok"};
                else
                    return new { Result = "ERROR", Message = "Group Already Exists" };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }

        [WebMethod(EnableSession = true)]
        public static object DeleteGroup(int pGroupId)
        {
            try
            {
                var deletedStudent = new GroupsBL().DeleteUserGroup((short)pGroupId);
                if(deletedStudent == true)
                return new { Result = "OK" };
                else
                    return new { Result = "ERROR" };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }

Selection operation with paging is working fine while any other operation like updation,deletion,creating results in same error. that is shown through Firebug plugin in the screenshot above or as follows.

{"Message":"Invalid web service call, missing value for parameter: \u0027pUserGroup\u0027.","StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary2 parameters)\r\n at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary2 parameters)\r\n at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}

share|improve this question

1 Answer

I found the bug , ex in case of update method the function I wrote is as follows

 public static object UpdateGroup(UserGroup pUserGroup)

while according to the creator of jTable plugin it should be as follows

public static object UpdateGroup(UserGroup record)// he hardcoded parameter name at somewhere.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.