dynamically adding validators

Discussion in 'ASP .Net Web Controls' started by jsh02_nova, Jun 5, 2004.

  1. jsh02_nova

    jsh02_nova Guest

    I'm adding validators dynamically to a page with the following code:

    MyVal = New RegularExpressionValidator
    With MyVal
    .ControlToValidate = tbAttrValue.Id
    .ValidationExpression = "(\w){1,2}"
    .ErrorMessage = "Warning W.R."
    .Display = ValidatorDisplay.Dynamic
    End With
    Me.Page.Validators.Add(MyVal)

    The project compiles and runs however, when I submit the page I get an
    'Object reference not set to an instance of an object.' exception. Has
    anybody else run across this problem, if so what am I missing?

    thx
    jsh02_nova, Jun 5, 2004
    #1
    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. =?Utf-8?B?RCBTaGVsZG9u?=

    Adding validators (programmatically) at PreRender stage

    =?Utf-8?B?RCBTaGVsZG9u?=, May 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    469
    =?Utf-8?B?RCBTaGVsZG9u?=
    May 12, 2004
  2. =?Utf-8?B?RCBTaGVsZG9u?=

    Help adding validators (programmatically) at PreRender stage

    =?Utf-8?B?RCBTaGVsZG9u?=, May 13, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    418
    =?Utf-8?B?RCBTaGVsZG9u?=
    May 13, 2004
  3. Ratman
    Replies:
    0
    Views:
    642
    Ratman
    Sep 14, 2004
  4. Jeffrey Todd
    Replies:
    1
    Views:
    4,085
    Peter Blum
    Jun 2, 2005
  5. =?Utf-8?B?TWlsZXM=?=
    Replies:
    3
    Views:
    2,017
    =?Utf-8?B?U3JlZWppdGggUmFt?=
    Aug 11, 2005
Loading...

Share This Page