我有一个主页面,其中有一些名为pagemethod的方法用于执行某些活动。在此主页面中使用了一个popuppanel(弹出面板内容页也具有pagemethods),用于显示某些详细信息。如果多次执行相同操作(即打开弹出面板多次),则在IE9之外的所有其他浏览器中都可以正常工作(甚至在IE8中也可以正常工作)。然而,首次执行是成功的。下面提供了正在使用的代码。
以下是使用的Scriptmanager:
页面方法:
Test1.aspx页面详情(此页面加载在弹出面板中):
以下是脚本代码:
页面方法:
如果在第二次执行相同的操作时(仅适用于IE9),将会抛出以下错误。
以下是使用的Scriptmanager:
<ajaxToolkit:ToolkitScriptManager runat="server" ID="TSCM1" EnablePageMethods="true" />
主页面中的脚本:
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);
}
页面方法:
[System.Web.Services.WebMethod(EnableSession = true)]
public static string mainPageMethod(String mainStr)
{
return mainStr + " Ok";
}
Test1.aspx页面详情(此页面加载在弹出面板中):
以下是脚本代码:
$(document).ready(function(){
PageMethods.Testpm("Test",fnd);
});
function fnd(str){
alert(str);
}
页面方法:
[System.Web.Services.WebMethod(EnableSession = true)]
public static string Testpm(String alrt)
{
return "Ok";
}
如果在第二次执行相同的操作时(仅适用于IE9),将会抛出以下错误。
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
重要提示:如果主页面没有任何页面方法,则工作正常。请帮我解决这个问题。
<%= MPE.ClientID %>
以外,您尝试过其他不同的方法来提供MPE的客户端ID吗?<%= %>
是Response.Write,它与MS Ajax的东西不兼容。 - Yuriy Galanter$find('Parent_ctl00_MPE').show()
。 - Yuriy Galanter