The CustomValidator Control

Controls the end we have included in ASP.NET is one that adds great flexibility
with our validation capabilities. We have a custom validator where we can write
our own function and pass the control value for this function.

Field: <asp:textbox id="textbox1" runat="server">
<asp: CustomValidator id = "valCustom" runat = "server"
ControlToValidate = "textbox1"
ClientValidationFunction = "ClientValidate"
OnServerValidate = "ServerValidate"
ErrorMessage = "* This box is not valid" dispaly = "dynamic"> *
</ Asp: CustomValidator>

You will see that there are two new attributes ClientValidationFunction
and OnServerValidate. This is to notify the control validation
function to pass values &#8203;&#8203;to ControlToValidate. ClientValidationFunction is
JavaScript functions are usually included in the HTML of your webpage. OnServerValidate
is a function that is server-side validation to check if the client does not
support for client side validation.

Client Validation function:

<script language="JavaScript">
<! -
/ * ... The code goes here ... * /
//-->
</ Script>

Validation Server functions:

Sub ServerValidate (objSource As Object, objArgs As ServerValidateEventsArgs)
'Code goes here
end Sub

Postingan populer dari blog ini

vb6 msflexgrid

Tutorial Visual Basic 6.0 : Listbox in VB6

Select Single Cell in MSHFlexgrid