Reg:-Custom validator

Results 1 to 2 of 2

Thread: Reg:-Custom validator

  1. #1
    Join Date
    Dec 1969

    Default Reg:-Custom validator

    hi all, <BR><BR>Pls help me in this regard.<BR><BR>i have a doubt in custom validator control. <BR>for eg:- <BR>In my web form i have like this, <BR> - name - text field <BR> - age - text field <BR> - ADD - button field <BR> - UPDATE - button field <BR> - QUERY - button field <BR><BR>i am doing validation for name field and checking the user entry against database. <BR>if it is not matching it should give message as &#039;Name is not found in database&#039;. <BR>otherwise it should display the records relater to that name. <BR>for that i am <BR>using custom validator servervalidate function (coding is like this) <BR><BR>&#060;asp:customvalidator id="Customvalidator5" <BR> style="Z-INDEX: 115; LEFT: 370px; POSITION: absolute; TOP: 266px" <BR> runat="server" Height="45px" Width="197px" <BR> ControlToValidate="txtname" <BR> ErrorMessage="NAME IS NOT MATCHING WITH DATABASE ENTRY"&#062; <BR>&#060;/asp:customvalidator&#062; <BR><BR>Private Sub Customvalidator5_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles Customvalidator5.ServerValidate <BR> Dim dv As DataView <BR> dv = ds.Tables(0).DefaultView <BR> Dim datarow As DataRowView <BR> Dim txtname As String <BR> args.IsValid = False &#039; Assume False <BR> &#039; Loop through table and compare each record against user&#039;s entry <BR> For Each datarow In dv <BR> &#039; Extract e-mail address from the current row <BR> txtname = datarow.Item("name").ToString() <BR> Response.Write("name is" & args.Value) <BR><BR> &#039; Compare e-mail address against user&#039;s entry <BR> If txtname = args.Value Then <BR> args.IsValid = True <BR> Exit For <BR> End If <BR> Next <BR><BR> End Sub <BR><BR>but my question is when i am clicking add button it validates the custom validator <BR>and it also processing the insertion into the database. <BR><BR><BR>in my case if name entered by the user is not found in the database it should not proceed <BR>further. <BR><BR>Thankx for reading this lengthy explanation, <BR><BR>thankx in advance, <BR>ulaga

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default I dont see the insert

    and i would also suggest you post this in the .NET forum<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts