UpdatePanel-没有错误,但是需要web.config设置吗?
|
我在使UpdatePanel在大型现有解决方案中工作时遇到问题。我有一个示例页面(如下),该页面可在新创建的演示网站中使用,但是在添加到现有目标网站时无法使用。
该功能是隔离下拉菜单的自动回发,因此我不会丢失FileUpload ASP控件的内容(出于安全原因,这样做是可行的,此处介绍了一些解决方案)
在目标(非演示)站点中,控件将页面罚款(包括intellisense)添加到页面中,并且页面呈现-但是更改下拉列表仍会执行回发操作,而不是对下拉框进行ajax化。
提到的目标解决方案以前是从ASP.NET v1.1升级的,所以我想知道配置中是否缺少某些内容?
我可以在呈现的HTML源代码中找到的唯一区别是非工作版本没有添加PageRequestManager,例如:
部分,但我尝试将其添加到目标站点,但无济于事。
<script type=\"text/javascript\">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize(\'ctl02\', document.getElementById(\'form1\'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls([\'tctl03\'], [], [], 90);
//]]>
</script>
样本页面:
<html xmlns=\"http://www.w3.org/1999/xhtml\">
<head runat=\"server\">
<title></title>
</head>
<body>
<form id=\"form1\" runat=\"server\">
<asp:ScriptManager ID=\"ScriptManager2\" runat=\"server\" />
<div>
<asp:UpdatePanel ID=\"UpdatePanel2\" runat=\"server\">
<ContentTemplate>
<asp:DropDownList runat=\"server\" ID=\"TestDropDown\" AutoPostBack=\"true\" OnSelectedIndexChanged=\"TestDropDown_SelectedIndexChanged\">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
</asp:DropDownList>
<asp:Literal runat=\"server\" Text=\"Original state\" ID=\"litText\" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:FileUpload ID=\"FileUpload2\" runat=\"server\" />
</div>
</form>
</body>
</html>
并在后面的代码中:
protected void TestDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
litText.Text = \"Ajax update. The file details should still be present below\";
}
我可以确认ScriptManager标记将以下内容添加到页面源中,因此我假定已经添加了Ajax Toolkit:
if (typeof(Sys) === \'undefined\') throw new Error(\'ASP.NET Ajax client-side framework failed to load.\');
而且在web.config中有以下部分:
<compilation defaultLanguage=\"c#\" debug=\"true\">
<assemblies>
<add assembly=\"System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>
[...]
<pages>
<controls>
<add tagPrefix=\"asp\" namespace=\"System.Web.UI\" assembly=\"System.Web.Extensions, Version=3.5.0.0, [...]
<add tagPrefix=\"asp\" namespace=\"System.Web.UI.WebControls\" assembly=\"System.Web.Extensions\" [...]
[...]
<httpHandlers>
<remove verb=\"*\" path=\"*.asmx\"/>
<add verb=\"*\" path=\"*.asmx\" validate=\"false\" type=\"System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>
<add verb=\"*\" path=\"*_AppService.axd\" validate=\"false\" type=\"System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>
<add verb=\"GET,HEAD\" path=\"ScriptResource.axd\" validate=\"false\" type=\"System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>
</httpHandlers>
<httpModules>
<add name=\"ScriptModule\" type=\"System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35\"/>
</httpModules>
该示例可在演示站点中使用,没有没有找到相关结果
已邀请:
1 个回复
磁辫覆氓
正如ScottGu的博客文章所述