2011-05-30 24 views
1

我遇到了UpdatePanel在大型現有解決方案中工作的問題。我有一個樣本頁面(下圖),該頁面在新創建的演示網站中工作,但未添加到現有目標網站時。UpdatePanel - 沒有錯誤,但需要web.config設置?

的功能是隔離一個下拉的自動回傳,所以我不失去的FileUpload ASP控制的內容(它這樣做的security reasons,有一些解決方案described here

目標(非演示)網站,控件添加到頁面罰款(inc intellisense),並且頁面呈現 - 但更改下拉列表仍然執行回發,而不是ajax - 如果下拉框。

提到先前從ASP.NET 1.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工具包已添加:

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> 

演示網站的抽樣作品,未經<觸發器>部分,但是我試着將它添加到TA rget網站,無濟於事。

回答

2

原來,以下應在web.config中進行設置,並且發生從ASP.NET V1.1升級的結果:

<xhtmlConformance mode="Legacy"/> 

作爲上ScottGu's blog post

討論
相關問題