Search code examples
c#asp.netupdatepanel

C# codebehind not getting hit when button clicked


 <asp:UpdatePanel runat="server" ID="userRemovalUpdatePanel">
    <ContentTemplate>
        <p><label>Remove: </label>
        <asp:DropDownList runat="server" ID="removeUserList" /></p>
        <br />
        <asp:Button runat="server" ID="removeUserBtn" Text="Remove User" 
            onclick="removeUserBtn_Click" CssClass="buttons"  />
        <p><label for="deleteStatus">Delete status: </label></p><br />
        <asp:Label runat="server" ID="deleteStatusLbl" Text="" Font-Size="Medium" Width="100" ForeColor="Red" />
    </ContentTemplate>
</asp:UpdatePanel>

I put a break point on the below code behind and it never gets hit. The code behind for this is:

protected void removeUserBtn_Click(object sender, EventArgs e)
{
    string userToDelete = removeUserList.SelectedValue;
    Business.User deleteUser = new Business.User();
    deleteStatusLbl.Text = deleteUser.DeleteUser(userToDelete);
    fillUserDropDown();
}

Solution

  • Do you have any validators on the page? Also place the Application_Error event in your Global.asax and try to log any errors that take place.

    Validators can prevent the postback and behave strangely with update panels sometimes.