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"/>
<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相關。
測試你的代碼,它工作正常(假設你有一個'ScriptManager'的地方)。也許問題出在'UpdatePanel_UnLoad' – VDWWD
我不知道爲什麼它不工作。我的表單中有ScriptManager。沒有UpdatePanel_UnLoad thorwn異常與取消註冊updatePanel相關。 –
剝離您的代碼,直到解決該錯誤。開始嘗試讓更新面板在沒有UpdateMode =「有條件的」和「OnUnload =」UpdatePanel_UnLoad「的情況下工作」 – VDWWD