Results 1 to 2 of 2

Thread: Checking for an empty string in an ASP.NET text box

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Barcelona
    Posts
    70

    Unhappy Checking for an empty string in an ASP.NET text box

    I' m desperate, nobody knows why this subroutine don' t check for an empty string in the text box 'activ2.Text' ? This sub is in an aspx page (asp.net vb.net).


    My complete Subroutine:
    Code:
    Sub ServerVal_activ(sender As Object, value As ServerValidateEventArgs)
    
      Try
    
        Dim var1 As Integer
        var1 = activ1.SelectedItem.Value    
        Dim var2 As String
        var2 = activ2.Text  
    
           If (var1 = 7) And (var2 = "") Then
             value.IsValid = False
             Exit Sub
    
           End If
    
      Catch exc As Exception
      End Try
    
      value.IsValid = True
    
    End Sub
    This Sub is triggered by the follow ASP.NET Custom Validator:
    Code:
    <asp:CustomValidator id="CustomValidator1" runat="server" ControlToValidate="var2" OnServerValidate="ServerVal_activ" Display="Dynamic">You must specify the activity.
    </asp:CustomValidator>
    What is the problem?...


    Thanks,
    Cesar

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Feb 2004
    Location
    Barcelona
    Posts
    70
    I already have solved the problem. The mistake was in a Custom Validator property.
    Code:
    <asp:CustomValidator id="CustomValidator1" runat="server" ControlToValidate="var2"....
    </asp:CustomValidator>
    The 'ControlToValidate' property not had to be there.

Posting Permissions

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



Click Here to Expand Forum to Full Width