Search code examples
c#asp.netautopostback

Multiple postbacks on a CheckBox with AutoPostBack


I've got a problem with a double post back after a onClick-Event on a CheckBox with AutoPostBack. When I click on a other server control the post back behaves as expected.

CheckBox definition:

<asp:CheckBox ID="chkCopyToRespDoc" runat="server" Text="<%$ Translation:JacieWeb.Admin.Notifications.CopyToRespDoc %>"
     OnCheckedChanged="chkCopyToRespDoc_CheckedChanged" AutoPostBack="true" CssClass="triggerOverlay" />

CodeBehind definition:

 protected void chkCopyToRespDoc_CheckedChanged(object sender, EventArgs e)
 {
     UpdateRecipients(RecipientsUpdateType.RespDoc);
 }

I tried to set the AutoWireUp attribute to false but it only stoped executing the Page_Load event on the first page load.

Did anyone have the same problem or know a solution?


Solution

  • I've found the solution by myself.

    I simply have to remove the AutoPostBack property of the check box and the double post back was gone.

    <asp:CheckBox ID="chkCopyToRespDoc" runat="server" Text="<%$ Translation:JacieWeb.Admin.Notifications.CopyToRespDoc %>"
     OnCheckedChanged="chkCopyToRespDoc_CheckedChanged" CssClass="triggerOverlay" />
    

    Thanks for all suggestions.

    Greatings