how to create a RegularExpressionValidator in runtime ? ?

Discussion in 'ASP .Net' started by Ricardo Corsi P. Cesar, Nov 26, 2003.

  1. Hi, i looking for example in asp.net (VB) to make the
    RegularExpressionValidator in runtime in my code behind.

    I found some similars codes, but nothing in VB..

    thanks!
     
    Ricardo Corsi P. Cesar, Nov 26, 2003
    #1
    1. Advertising

  2. Ricardo Corsi P. Cesar

    Miha Markic Guest

    Can you post similar code?

    --
    Miha Markic - RightHand .NET consulting & software development
    miha at rthand com

    "Ricardo Corsi P. Cesar" <> wrote in message
    news:...
    > Hi, i looking for example in asp.net (VB) to make the
    > RegularExpressionValidator in runtime in my code behind.
    >
    > I found some similars codes, but nothing in VB..
    >
    > thanks!
    >
    >
     
    Miha Markic, Nov 26, 2003
    #2
    1. Advertising

  3. Sure, here we go:

    Public Shared Function Test(ByVal campo As TextBox)
    Dim rf As New RegularExpressionValidator
    rf.ID = "rf"
    rf.Enabled = True
    rf.Visible = True
    rf.Display = ValidatorDisplay.Dynamic
    rf.ErrorMessage = "You must enter a value"
    rf.Text = "*"
    rf.ValidationExpression = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    rf.ControlToValidate = (campo.ID)
    rf.EnableClientScript = True
    rf.EnableViewState = False
    rf.Validate = campo
    End Function

    but this code above, it seems to do nothing when i use it on a button (on
    click event). Something is missing to this simple code work fine.

    could you help me up ?





    "Miha Markic" <miha at rthand com> wrote in message
    news:...
    > Can you post similar code?
    >
    > --
    > Miha Markic - RightHand .NET consulting & software development
    > miha at rthand com
    >
    > "Ricardo Corsi P. Cesar" <> wrote in message
    > news:...
    > > Hi, i looking for example in asp.net (VB) to make the
    > > RegularExpressionValidator in runtime in my code behind.
    > >
    > > I found some similars codes, but nothing in VB..
    > >
    > > thanks!
    > >
    > >

    >
    >
     
    Ricardo Corsi P. Cesar, Nov 26, 2003
    #3
  4. Ricardo Corsi P. Cesar

    Nick Hertl Guest

    I'm having trouble getting a RegularExpressionValidator to work at all
    because I've never needed one, but it looks like you might need to make
    this change:

    >rf.ValidationExpression = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

    rf.ValidationExpression = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

    That magical "@" will make the "\" chars in your regexp literal instead of
    escape characters.

    If you are still having trouble, let me know and I will dig deaper to see
    if I can get you a solid example.

    ----------------
    This posting is provided "AS IS" with no warranties, and
    confers no rights.

    Please do not send e-mail directly to this alias. This
    alias is for newsgroup purposes only.

    Thanks
    Nick

    --------------------
    >From: "Ricardo Corsi P. Cesar" <>
    >References: <>

    <>
    >Subject: Re: how to create a RegularExpressionValidator in runtime ? ?
    >Date: Wed, 26 Nov 2003 13:41:29 -0200
    >Lines: 48
    >X-Priority: 3
    >X-MSMail-Priority: Normal
    >X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    >Message-ID: <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >NNTP-Posting-Host: 200-171-96-217.speedyterra.com.br 200.171.96.217
    >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
    >Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:193512
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >Sure, here we go:
    >
    >Public Shared Function Test(ByVal campo As TextBox)
    >Dim rf As New RegularExpressionValidator
    >rf.ID = "rf"
    >rf.Enabled = True
    >rf.Visible = True
    >rf.Display = ValidatorDisplay.Dynamic
    >rf.ErrorMessage = "You must enter a value"
    >rf.Text = "*"
    >rf.ValidationExpression = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
    >rf.ControlToValidate = (campo.ID)
    >rf.EnableClientScript = True
    >rf.EnableViewState = False
    >rf.Validate = campo
    >End Function
    >
    >but this code above, it seems to do nothing when i use it on a button (on
    >click event). Something is missing to this simple code work fine.
    >
    >could you help me up ?
    >
    >
    >
    >
    >
    >"Miha Markic" <miha at rthand com> wrote in message
    >news:...
    >> Can you post similar code?
    >>
    >> --
    >> Miha Markic - RightHand .NET consulting & software development
    >> miha at rthand com
    >>
    >> "Ricardo Corsi P. Cesar" <> wrote in message
    >> news:...
    >> > Hi, i looking for example in asp.net (VB) to make the
    >> > RegularExpressionValidator in runtime in my code behind.
    >> >
    >> > I found some similars codes, but nothing in VB..
    >> >
    >> > thanks!
    >> >
    >> >

    >>
    >>

    >
    >
    >
     
    Nick Hertl, Dec 15, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Oleg Ogurok
    Replies:
    1
    Views:
    6,398
    William F. Robertson, Jr.
    Jun 25, 2003
  2. Helixpoint

    RegularExpressionValidator for money??

    Helixpoint, Jun 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,829
    Helixpoint
    Jul 1, 2003
  3. Salim Afþar

    regularexpressionvalidator numeric control

    Salim Afþar, Aug 4, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    2,602
    Vincent V
    Aug 5, 2003
  4. BH
    Replies:
    0
    Views:
    558
  5. Ananda Sim
    Replies:
    0
    Views:
    494
    Ananda Sim
    Aug 18, 2003
Loading...

Share This Page