2016-08-20 88 views
1

我的代碼有問題嗎? 更新面板不顯示按鈕後,要求標籤上單擊更新面板不響應按鈕事件

 <asp:UpdatePanel runat="server" ID="updatesPanel" UpdateMode="Conditional" OnUnload="UpdatePanel_UnLoad"> 
       <ContentTemplate> 
        <asp:Label ID="lblUpdateSavedSuccess" Text=" Changes Saved Successfully :) " runat="server" Font-Bold="True" 
         Font-Names="Comic Sans MS" Font-Size="X-Large" ForeColor="#00CC00" Visible="false"/><br /> 

        <asp:Label ID="lblUpdateSavedFailed" Text=" Something Went worng :(" runat="server" Font-Bold="True" 
         Font-Names="Comic Sans MS" Font-Size="X-Large" ForeColor="Red" Visible="false"/><br /> 

        <asp:Label ID="lblUpdateNoChanges" Text=" There is now changes :| " runat="server" Font-Bold="True" 
         Font-Names="Comic Sans MS" Font-Size="X-Large" ForeColor="#0099FF" Visible="False"/> 
        <asp:Button ID="btnUpdateInfo" runat="server" Text ="Save Changes" OnClick="btnUpdateInfo_Click"/>&nbsp;&nbsp;&nbsp; 
        <asp:Button ID="deleteUser" runat="server" Text="Delete User" Width="118px" OnClick="deleteUser_Click" /> 

        <br /><br /> 
       </ContentTemplate> 
      </asp:UpdatePanel> 

我的按鈕事件:

protected void btnUpdateInfo_Click(object sender, EventArgs e) 
    { 

       lblUpdateSavedSuccess.Visible = true; 
       lblUpdateSavedFailed.Visible = false; 
       lblUpdateNoChanges.Visible = false; 
    } 

我在我更新面板使用onunload的=「UpdatePanel_UnLoad」,因爲雖然complie我的工作,我有一個異常與取消註冊updatePanel相關。

+0

測試你的代碼,它工作正常(假設你有一個'ScriptManager'的地方)。也許問題出在'UpdatePanel_UnLoad' – VDWWD

+0

我不知道爲什麼它不工作。我的表單中有ScriptManager。沒有UpdatePanel_UnLoad thorwn異常與取消註冊updatePanel相關。 –

+0

剝離您的代碼,直到解決該錯誤。開始嘗試讓更新面板在沒有UpdateMode =「有條件的」和「OnUnload =」UpdatePanel_UnLoad「的情況下工作」 – VDWWD

回答

0

我試過在我身邊複製你的問題,但一切工作正常。通常情況下,如果有AJAX控件的問題,這是因爲你有另一個Java腳本庫添加到與AJAX scrits衝突的頁面。你可以在網頁運行時按下Chrome瀏覽器中的Ctrl+Shift+J並檢查瀏覽器控制檯來確認。

我也有在JS腳本沒有被正確加載AJAX和添加EnableCdn="true"到ScriptManager的固定probem過去的問題:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true"></asp:ScriptManager> 

希望這有助於你在修理你的問題。