Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Fix “PageMethods Is Undefined” Error in Web Forms

Fix “PageMethods Is Undefined” Error in Web Forms

New Discussion
Kenny
Kenny asked on Jan 22, 2014 1:33 PM

Why I keep getting PageMethods not defined error?

<%@ Page  Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="~/AccessRights.aspx.vb" Inherits="AccessRights" title="Access Rights Matrix" 
validateRequest="false" EnableEventValidation="false" MaintainScrollPositionOnPostback="true"
 EnableSessionState="True"  %>
 
 
<%@ Register Assembly="Infragistics45.Web.v13.2, Version=13.2.20132.2028, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.NavigationControls" TagPrefix="ig" %>
 
<%@ Register Assembly="Infragistics45.Web.v13.2, Version=13.2.20132.2028, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb" Namespace="Infragistics.Web.UI.GridControls" TagPrefix="ig" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc6" %>
 
<%@ MasterType VirtualPath="~/MasterPage.master" %>
<%@ Import Namespace="System.Data.SqlClient" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
     <script type="text/javascript" src ="EMS.js">
    </script>   
 
    <link href="css/CustomPager.css" rel="stylesheet" />
 
 
        <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" ScriptMode="Release" LoadScriptsBeforeUI="true" ></asp:ScriptManager>
 
 
    <script type ="text/javascript" id="igClientScript">
        function WebDataGrid1_Editing_CellValueChanged(sender, e) {
            var a = $find('<%= WebDataGrid1.ClientID %>');
            var cell = e.get_cell();
 
            if (cell.get_column().get_key() == "Read") {
                if (cell.get_value() == false) {
                    cell.get_row().get_cell(2).set_value(false);
                    cell.get_row().get_cell(3).set_value(false);
                }
            }
 
            if (cell.get_column().get_key() == "Update") {
                if (cell.get_value() == true) {
                    cell.get_row().get_cell(1).set_value(true);
                }
            }
 
            if (cell.get_column().get_key() == "Delete") {
                if (cell.get_value() == true) {
                    cell.get_row().get_cell(1).set_value(true);
                }
            }
 
            if (a.get_behaviors().get_editingCore().get_editedRows().length > 0) {
                var x = document.getElementById('<%= HiddenFieldCancel.ClientID%>');
                x.value = 'No';
 
                document.getElementById('<%=ButtonLoadMatrix.ClientID%>').disabled = true;
                document.getElementById('<%=DropDownListGroup.ClientID%>').disabled = true;
                document.getElementById('<%=DropDownListModule.ClientID%>').disabled = true;
                
                setMenu(false);
            }
            else {
                var x = document.getElementById('<%= HiddenFieldCancel.ClientID%>');
                x.value = 'Yes';
 
                document.getElementById('<%=ButtonLoadMatrix.ClientID%>').disabled = false;
                document.getElementById('<%=DropDownListGroup.ClientID%>').disabled = false;
                document.getElementById('<%=DropDownListModule.ClientID%>').disabled = false;
 
                setMenu(true);
            }
        }
 
        function setMenu(parMenu) {
            var menu = $find('<%=Master.MasterMenu.ClientID()%>');  // Get the MainMenu on the master page
        
           

var result = PageMethods.menuActive(false, OnSuccess, OnError);

       
     
 
 
//            menu.disabled = false;
 
       //     var item = menu.findItemByText("Setup");
       //     item.get_element().style.cssText = "display: none;";  // Hide the item
 
    
        //    menu.getItems().getItem(0).set_enabled(parMenu);
        //    menu.getItems().getItem(1).set_enabled(parMenu);
        //    menu.getItems().getItem(2).set_enabled(parMenu);
        }
 
        function OnSuccess(response) {
            alert(response);
        }
        function OnError(error) {
            alert(error);
        }
 
        function WebDataGrid1_Editing_CellValueChanging(sender, e) {
            if (e.get_cell().get_column().get_key() == "Read") 
            {
            }
            else {
                if (e.get_cell().get_row().get_tag() == true) {
                    e.set_cancel(true);
                }
            }
        }
 
    </script>
 
    <script type="text/javascript">
        var checkChangesEnabled = true;
        window.onbeforeunload = yyy;  // confirmExit;    // yyy;
 
        function yyy() {
            if (document.getElementById('<%=ButtonLoadMatrix.ClientID%>').disabled == true) {
                if (checkChangesEnabled) {
                    if (navigator.appName == "Microsoft Internet Explorer") {
                        // IE only...
                        window.event.returnValue = "Changes you have made will be saved!";
                    }
                    else {
                        // Other browsers...
                        return "Changes you have made will be saved!";
                    }
                    disableCheck();
                }
            }
        }
 
        function confirmExit() {
            if (document.getElementById('<%=ButtonLoadMatrix.ClientID%>').disabled == true)
            {
                if (checkChangesEnabled) {
                    event.returnValue = "Changes you have made will not be saved!";
                    disableCheck();
                }
            }
        }
 
        function disableCheck() {
            checkChangesEnabled = false;
            setTimeout("enableCheck()", "100");
        }
 
        function enableCheck() {
            checkChangesEnabled = true;
        }
 
        function xxx() {
            var x = document.getElementById('<%= HiddenFieldCancel.ClientID%>');
            x.value = 'Yes';
            __doPostBack('<%= ButtonUpdate.UniqueID%>', '');
 
            setMenu(true);
        }
 
        function checkedAll(parCellNo)
        {
            var grid = $find('<%=WebDataGrid1.ClientID%>');
            var rowsLength = grid.get_rows().get_length();
 
            for (var i = 0; i < rowsLength; i++) {
                var currentRow = grid.get_rows().get_row(i);
                var currentCell = currentRow.get_cell(parCellNo);
                var currentVal = currentCell.get_value();
 
                if (currentCell.get_row().get_tag() == true) {
                    if (parCellNo != 1)
                        grid.get_rows().get_row(i).get_cell(parCellNo).set_value(false);
                    else
                        grid.get_rows().get_row(i).get_cell(parCellNo).set_value(true);
                }
                else
                    grid.get_rows().get_row(i).get_cell(parCellNo).set_value(true);
            }
        }
 
        function uncheckedAll(parCellNo) {
            var grid = $find('<%=WebDataGrid1.ClientID%>');
            var rowsLength = grid.get_rows().get_length();
 
            for (var i = 0; i < rowsLength; i++) {
                var currentRow = grid.get_rows().get_row(i);
                var currentCell = currentRow.get_cell(parCellNo);
                var currentVal = currentCell.get_value();
 
                grid.get_rows().get_row(i).get_cell(parCellNo).set_value(false);
            }
        }
    </script>
 
 
      <asp:UpdatePanel ID="UpdatePanel1" runat="server">
         <ContentTemplate>
            <asp:Panel 
                ID="PanelTop" runat="server" Style="z-index: 0; left: 0%; position: relative; top: 0%; width :100%; height : 30px;" BackColor="Transparent">
 
                <asp:Label
                    Style="border-width: thin; PADDING-LEFT: 5px; Z-INDEX: 101; LEFT: 10px; POSITION: absolute; TOP: 5px; width: 83px;"
                    ID="LabelModule"
                    runat="server"
                    Font-Bold="False"
                    Height="20px"
                    Font-Names="Tahoma"
                    BorderWidth="1px"
                    BorderStyle="Ridge"
                    ForeColor="White"
                    Font-Size="12px"
                    Text="Module"
                    BackColor="#C00000" CssClass="LabelClass"> </asp:Label>
 
                <asp:DropDownList 
                    ID="DropDownListModule" 
                    runat="server" 
                    AppendDataBoundItems="True"
                    AutoPostBack="False" 
                    Font-Names="Tahoma" 
                    Height="22px" 
                    Style="border: 1px solid #ccccff; padding-left: 5px; z-index: 101; left: 104px; position: absolute; top: 6px; font-size: 12px; font-family: tahoma;" 
                    Width="330px" 
                    Font-Size="12px" >
                    <asp:ListItem Selected="True">IRAS</asp:ListItem>
                </asp:DropDownList>
                            
                <asp:Label 
                    ID="LabelGroup" 
                    runat="server" 
                    BackColor="#C00000" 
                    BorderStyle="Ridge"
                    Font-Bold="False" 
                    Font-Names="Tahoma" 
                    Font-Size="12px" 
                    Height="20px" 
                    Style="border-width: thin; padding-left: 5px; z-index: 102; left: 455px; font-family: Tahoma; position: absolute; top: 5px; width: 84px;" 
                    Text="Group" 
                    BorderWidth="1px" 
                    ForeColor="White"></asp:Label>
                                
                <asp:DropDownList 
                    ID="DropDownListGroup" 
                    runat="server" 
                    AppendDataBoundItems="True"
                    AutoPostBack="False" 
                    DataTextField="User Group" 
                    DataValueField="User Group" 
                    Font-Names="Tahoma"
                    Height="22px" 
                    Style="border: 1px solid #ccccff; padding-left: 5px; z-index: 103; left: 551px; position: absolute; top: 6px; font-size: 12px; font-family: tahoma;" 
                    Width="330px" 
                    Font-Size="12px" >
                    <asp:ListItem>(empty)</asp:ListItem>
                </asp:DropDownList>
                            
                <asp:Button 
                    ID="ButtonLoadMatrix" 
                    runat="server" 
                    Height="24px" 
                    Style="z-index: 105; left: 895px; position: absolute; top: 3px" 
                    Text="Load Matrix" 
                    Width="87px" 
                    OnClick="ButtonLoadMatrix_Click" 
                    Font-Names="Tahoma" 
                    Font-Size="12px" />
            </asp:Panel>
 
            <asp:Panel 
                ID="PanelGrid" 
                runat="server"  
                Height="450px" 
                Width="100%" 
                style="position: relative; left: 0%; top: 0%;">
 
 
                <asp:HiddenField ID="HiddenFieldCancel" runat="server" Value="No" />
                <ig:WebDataGrid 
                    ID="WebDataGrid1" 
                    runat="server" 
                    AutoGenerateColumns="False" 
                    DataSourceID="SqlDataSource1" 
                    Height="98%" 
                    Width="100%" 
                    DataKeyFields="System, User_Group, Function" EnableAjaxViewState="False">
                    <Columns>
                        <ig:BoundDataField DataFieldName="Function" Key="Function" Width ="50%">
                            <Header Text="Function">
                            </Header>
                        </ig:BoundDataField>
                        <ig:BoundCheckBoxField DataFieldName="Read" Key="Read" Width ="10%">
                            <Header Text="Read">
                            </Header>
                        </ig:BoundCheckBoxField>
                        <ig:BoundCheckBoxField DataFieldName="Update" Key="Update" Width ="10%">
                            <Header Text="Update">
                            </Header>
                        </ig:BoundCheckBoxField>
                        <ig:BoundCheckBoxField DataFieldName="Delete" Key="Delete" Width ="10%">
                            <Header Text="Delete">
                            </Header>
                        </ig:BoundCheckBoxField>
                        <ig:BoundDataField DataFieldName="Function_Type" Key="Function_Type">
                            <Header Text="Function_Type">
                            </Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="System" Key="System" Hidden ="true" >
                            <Header Text="System">
                            </Header>
                        </ig:BoundDataField>
                        <ig:BoundDataField DataFieldName="User_Group" Key="User_Group" Hidden ="true">
                            <Header Text="User_Group">
                            </Header>
                        </ig:BoundDataField>
                    </Columns>
                    <Behaviors>
                        <ig:EditingCore AutoCRUD="False" BatchUpdating="True">
                            <EditingClientEvents CellValueChanged="WebDataGrid1_Editing_CellValueChanged" CellValueChanging="WebDataGrid1_Editing_CellValueChanging" />
                            <Behaviors>
                                <ig:CellEditing>
                                    <ColumnSettings >
                                        <ig:EditingColumnSetting ColumnKey="Function" ReadOnly ="true" />
                                        <ig:EditingColumnSetting ColumnKey="Read" ReadOnly ="false" />
                                        <ig:EditingColumnSetting ColumnKey="Update" ReadOnly ="false" />
                                        <ig:EditingColumnSetting ColumnKey="Delete" ReadOnly ="false" />
                                        <ig:EditingColumnSetting ColumnKey="Function_type" ReadOnly ="true" />
                                        <ig:EditingColumnSetting ColumnKey="System" ReadOnly ="true" />
                                        <ig:EditingColumnSetting ColumnKey="User_Group" ReadOnly ="true" />
                                    </ColumnSettings>
                                </ig:CellEditing>
                            </Behaviors>
                        </ig:EditingCore>
                        <ig:Selection>
                        </ig:Selection>
                        <ig:RowSelectors>
                        </ig:RowSelectors>
                        <ig:Sorting>
                        </ig:Sorting>
                        <ig:Activation>
                        </ig:Activation>
                    </Behaviors>
                </ig:WebDataGrid>
 
 
                <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                    ConnectionString="<%$ ConnectionStrings:IRASConnectionString %>"
                    DeleteCommand="DELETE FROM [Access Rights] WHERE [Function] = @original_Function AND [System] = @original_System AND [User Group] = @original_User_Group" 
                    InsertCommand="INSERT INTO [Access Rights] ([Function], [Read], [Update], [Delete], [Function Type], [System], [User Group]) VALUES (@Function, @Read, @Update, @Delete, @Function_Type, @System, @User_Group)" OldValuesParameterFormatString="original_{0}" 
                    SelectCommand="SELECT [Function], [Read], [Update], [Delete], [Function Type] AS Function_Type, [System], [User Group] AS User_Group FROM [Access Rights] WHERE (([System] = @System) AND ([User Group] = @User_Group)) ORDER BY [Function]" 
                    UpdateCommand="UPDATE [Access Rights] SET [Read] = @Read, [Update] = @Update, [Delete] = @Delete, [Function Type] = @Function_Type WHERE [Function] = @original_Function AND [System] = @original_System AND [User Group] = @original_User_Group">
                    <DeleteParameters>
                        <asp:Parameter Name="original_Function" Type="String" />
                        <asp:Parameter Name="original_System" Type="String" />
                        <asp:Parameter Name="original_User_Group" Type="String" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Function" Type="String" />
                        <asp:Parameter Name="Read" Type="Boolean" />
                        <asp:Parameter Name="Update" Type="Boolean" />
                        <asp:Parameter Name="Delete" Type="Boolean" />
                        <asp:Parameter Name="Function_Type" Type="String" />
                        <asp:Parameter Name="System" Type="String" />
                        <asp:Parameter Name="User_Group" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="DropDownListModule" Name="System" PropertyName="SelectedValue" Type="String" />
                        <asp:ControlParameter ControlID="DropDownListGroup" Name="User_Group" PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Read" Type="Boolean" />
                        <asp:Parameter Name="Update" Type="Boolean" />
                        <asp:Parameter Name="Delete" Type="Boolean" />
                        <asp:Parameter Name="Function_Type" Type="String" />
                        <asp:Parameter Name="original_Function" Type="String" />
                        <asp:Parameter Name="original_System" Type="String" />
                        <asp:Parameter Name="original_User_Group" Type="String" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </asp:Panel> 
                        
            <asp:Panel 
                ID="PanelAction" 
                runat="server" 
                BackColor="LightSteelBlue" 
                Height="36px" 
                Style="z-index: 101; left: 0px; position: relative; background-color: #c00000;" 
                Width="1005px">
 
                <asp:Label 
                    ID="LabelMode" 
                    runat="server" 
                    BorderStyle="None" 
                    Font-Bold="False" 
                    Font-Names="Tahoma"
                    Font-Underline="False" 
                    Style="z-index: 100; left: 12px; font-family: Tahoma; position: absolute; top: 8px; FONT-SIZE: 12px; color: white;" 
                    Text="Enquiry Mode" 
                    Width="92px" ForeColor="Black" Font-Size="12px"></asp:Label>
 
                   <asp:Button 
                    ID="ButtonEnableRead" 
                    runat="server" 
                    Enabled="True" 
                    Height="28px" 
                    Style="z-index: 101; left: 176px; position: absolute; top: 4px"
                    Text="Enable All Read" 
                    Width="108px" Font-Names="Tahoma" Font-Size="12px" OnClientClick="checkedAll(1); return false;" />
                                
                  <asp:Button 
                    ID="ButtonDisableRead" 
                    runat="server" 
                    Enabled="True" 
                    Height="28px" 
                    Style="z-index: 101; left: 285px; position: absolute; top: 4px"
                    Text="Disable All Read" 
                    Width="108px" Font-Names="Tahoma" Font-Size="12px" OnClientClick="uncheckedAll(1); return false;" />
 
                 <asp:Button 
                    ID="ButtonEnableUpdate" 
                    runat="server" 
                    Enabled="True" 
                    Height="28px" 
                    Style="z-index: 101; left: 394px; position: absolute; top: 4px"
                    Text="Enable All Update" 
                    Width="108px" Font-Names="Tahoma" Font-Size="12px" OnClientClick="checkedAll(2); return false;" />
                                
                  <asp:Button 
                    ID="ButtonDisableUpdate" 
                    runat="server" 
                    Enabled="True" 
                    Height="28px" 
                    Style="z-index: 101; left: 503px; position: absolute; top: 4px"
                    Text="Disable All Update" 
                    Width="108px" Font-Names="Tahoma" Font-Size="12px" OnClientClick="uncheckedAll(2); return false;" />
 
                 <asp:Button 
                    ID="ButtonEnableDelete" 
                    runat="server" 
                    Enabled="True" 
                    Height="28px" 
                    Style="z-index: 101; left: 612px; position: absolute; top: 4px"
                    Text="Enable All Delete" 
                    Width="108px" Font-Names="Tahoma" Font-Size="12px" OnClientClick="checkedAll(3); return false;" />
                                
                  <asp:Button 
                    ID="ButtonDisableDelete" 
                    runat="server" 
                    Enabled="True" 
                    Height="28px" 
                    Style="z-index: 101; left: 721px; position: absolute; top: 4px"
                    Text="Disable All Delete" 
                    Width="108px" Font-Names="Tahoma" Font-Size="12px" OnClientClick="uncheckedAll(3); return false;" />
 
                <asp:Button 
                    ID="ButtonCancel" 
                    runat="server" 
                    Enabled="False" 
                    Height="28px" 
                    Style="z-index: 101; left: 915px; position: absolute; top: 4px"
                    Text="Cancel" 
                    Width="84px" Font-Names="Tahoma" Font-Size="12px" OnClientClick="return xxx();" />
                            
                <asp:Button 
                    ID="ButtonUpdate" 
                    runat="server" 
                    Enabled="False" 
                    Height="28px" 
                    Style="z-index: 102; left: 830px; position: absolute; top: 4px" 
                    Text="Save" 
                    Width="84px" Font-Names="Tahoma" Font-Size="12px" />
            </asp:Panel>
         </ContentTemplate>
     </asp:UpdatePanel> 
 
 
    <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1" Visible="true"    >
        <ProgressTemplate>
            <div 
                style="position:absolute;  
                top : 30%; 
                left : 40%;
                width:30%; 
                height:12%; 
                background-color:black; 
                color:yellow; 
                border-top : ridge 3px gray;
                border-bottom : ridge 3px gray;
                border-left : ridge 3px gray;
                border-right : ridge 3px gray;
                margin-left:auto;margin-right:auto;">
                <br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Please wait ... <img src="ajax-loader-yellow-black.gif" style="position:relative;" />
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>
Sign In to post a reply

Replies

  • 0
    Kenny
    Kenny answered on Jan 13, 2014 4:57 PM

    This is the exact error message:

    0x800a1391 – Microsoft JScript runtime error: 'PageMethods' is undefined

    • 0
      [Infragistics] Petar Ivanov
      [Infragistics] Petar Ivanov answered on Jan 22, 2014 1:33 PM

      Hello tarney,

      This issue may be related to the respectice WebMethod definition. Please ensure that the WebMethod is defined in the code behind as defined at:

      http://msdn.microsoft.com/en-us/library/bb398998%28v=vs.110%29.aspx

      Please do not hesitate to contact me if you have any questions.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Kenny
Favorites
0
Replies
2
Created On
Jan 22, 2014
Last Post
12 years, 8 months ago

Suggested Discussions

Created by

Created on

Jan 22, 2014 1:33 PM

Last activity on

Feb 12, 2026 8:45 AM