Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pagemethods in popuppanel does not load the second time in IE9

I have a main page which has some pagemethod called to perform some activities. A popuppanel(popuppanel content page also have pagemethods) is used within this main page to show some details. If the same is executed multiple times (i.e., opening the popup panel many times), it is working in all other browsers other than IE9 (working even in IE8). However, first time execution is successful. The code that is being used is provided below.

Scriptmanager used as follow:

<ajaxToolkit:ToolkitScriptManager runat="server" ID="TSCM1" EnablePageMethods="true" />

Script In Main Page:

function Clkd(){
     var ppnl=document.getElementById("if1");
     ppnl.src="Test1.aspx";
     $find('<%= MPE.ClientID %>').show();
}

function Clkd2(){
     var ppnl=document.getElementById("if1");
     ppnl.src="";
     $find('<%= MPE.ClientID %>').hide();
}

$(document).ready(function(){
     PageMethods.mainPageMethod("MainTest",cbackfn);
});

function cbackfn(str){
     alert(str);
}

Page method:

 [System.Web.Services.WebMethod(EnableSession = true)]
        public static string mainPageMethod(String mainStr)
        {
            return mainStr + " Ok";
        }

Test1.aspx page Details (this is the page loaded inside the popup panel):

Script code below :

$(document).ready(function(){
     PageMethods.Testpm("Test",fnd);
});

function fnd(str){
     alert(str);
}

Page method:

 [System.Web.Services.WebMethod(EnableSession = true)]
        public static string Testpm(String alrt)
        {
            return "Ok";
        }

The following error is thrown if the same is executed the second time (in IE9 only)

SCRIPT5007: Unable to set value of the property '_UpdateProgress': object is null or undefined 
ScriptResource.axd?........

SCRIPT5007: Unable to get value of the property 'WebServiceProxy': object is null or undefined 
Test1.aspx, line 66 character 1

SCRIPT5007: Unable to get value of the property 'DomElement': object is null or undefined 
ScriptResource.axd?......, line 2 character 18851

SCRIPT5007: Unable to get value of the property 'add_init': object is null or undefined 
Test1.aspx, line 97 character 122

SCRIPT438: Object doesn't support property or method 'Testpm' 
Test1.aspx, line 11 character 4

Important Note: if main page does not have any pagemethods then its working fine. please help me out from this issue..

like image 828
RGA Avatar asked Sep 03 '13 10:09

RGA


1 Answers

You should have added relevant HTML, that might have helped others to help you out.

Well I used your code and added missing code and when I runt it, it is working fine in all browsers including IE9.

Please find below code:

Main Page (Default.aspx):

<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        function Clkd() {
            var ppnl = document.getElementById("if1");
            ppnl.src = "test.aspx";
            $find('<%= MPE.ClientID %>').show();
        }

        function Clkd2() {
            var ppnl = document.getElementById("if1");
            ppnl.src = "";
            $find('<%= MPE.ClientID %>').hide();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <cc1:ToolkitScriptManager runat="server" ID="scriptmanager1">
    </cc1:ToolkitScriptManager>
    <asp:Panel ID="pnl1" runat="server">
        <iframe id="if1"></iframe>
        <asp:Button ID="btnHidePopup" runat="server" Text="Hide" />
    </asp:Panel>
    <asp:Button ID="btnShowPopup" runat="server" Text="Show" OnClientClick="Clkd();" />
    <cc1:ModalPopupExtender ID="MPE" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnl1"
        DropShadow="true" OkControlID="btnHidePopup" OnOkScript="Clkd2()" CancelControlID="btnHidePopup">
    </cc1:ModalPopupExtender>
    </form>
</body>

Test.aspx:

<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            PageMethods.Testpm("Test", fnd);
        });
        function fnd(str) {
            alert(str);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <cc1:ToolkitScriptManager runat="server" ID="scriptmanageriframe" EnablePageMethods="true">
    </cc1:ToolkitScriptManager>
    Hello World this is game.
    </div>
    </form>
</body>

Test.aspx.ce (Webmethod):

 [System.Web.Services.WebMethod(EnableSession = true)]
        public static string Testpm(String alrt)
        {

            return "Ok";
        }

I hope it helps!

like image 80
Nilesh Thakkar Avatar answered Oct 17 '22 09:10

Nilesh Thakkar