Est. Reading Time: 4 minutes
Now let’s look at your submit button. In this example it is an image button.
<asp:ImageButton imageUrl=”/images/buttons/submit.gif” AlternateText=”Submit” OnClientClick=”return validate(registrationForm)” width=”92″ height=”24″ tabindex=”12″ runat=”server” > </asp:ImageButton>
<asp:customvalidator id=”registerPage” onServerValidate=”CheckPage” ErrorMessage=”” Runat=”server” ValidationGroup=”Page”></asp:customvalidator>
We will capture the Click event in our code behind with the following code: Execute the custom validator, that will execute your code behind validation.
Sub btnSubmit_Click(ByVal sender AsObject, ByVal e AsSystem.Web.UI.ImageClickEventArgs) Handles btnSubmit.Click registerPage.Validate() If (Page.IsValid) Then ProcessForm() End if
Below is the validation routine referenced by the custom validator.