【发布时间】:2013-09-06 13:02:51
【问题描述】:
我有一个主页,其中调用了一些 pagemethod 来执行一些活动。 popuppanel(popuppanel 内容页面也有 pagemethods)用于在这个主页中显示一些细节。如果多次执行相同的操作(即多次打开弹出面板),则它在所有其他浏览器除 IE9 中工作(即使在 IE8 中也工作)。但是,第一次执行是成功。下面提供了正在使用的代码。
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
重要提示:如果主页没有任何 pagemethods,那么它可以正常工作。 请帮我解决这个问题..
【问题讨论】:
-
除了
<%= MPE.ClientID %>之外,您是否尝试过使用不同的方法来提供 MPE 的客户端 ID?<%= %>是 Response.Write,它与 MS Ajax 的东西不兼容 -
是的,我试过但同样的错误
-
你能发布修改后的代码吗?
-
只需将 '' 更改为 'MPE' 并使用 '#MPE' 进行检查
-
不,它仍然必须是有效的客户 ID。作为测试,您能否在呈现的 HTML 中验证真实的客户端 ID 并尝试使用它?例如。它可能类似于
$find('Parent_ctl00_MPE').show()
标签: c# javascript internet-explorer-9 modalpopupextender pagemethods