I have a user control with a delete button. When a button is clicked, an event fires which deletes a record from the database. Now, the control is placed in
UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
It turns out the
PostBack cannot occur if the form is not
IsValid regardless of what element causes it. As long as that element (button) is inside the form with
runat="server"that is invalid, the posback will not happen.
A very simple workaround is to just make the Button in my user control bypass validation:
CausesValidation="False" (thanks to this question).
Another solution and maybe a more efficient one, is to use
ValidationGroup. This way, all
TextBoxes together with the Submit
Button will belong to one group, and those controls that do not belong to that group will NOT be validated. In fact, they might have their own
ValidationGroup; this will avoid interference between different controls within one Web Form.