Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dynamically creating controls, validators, using autopost back

Reply
Thread Tools

dynamically creating controls, validators, using autopost back

 
 
=?Utf-8?B?TFU=?=
Guest
Posts: n/a
 
      03-29-2005
I query database,
QuestionID | QuestionName | QuestionType
1 | FirstName | TextBox
2 | LastName | TextBox

Loop
Create TextBox
Create RequiredFieldValidator

Here is my problem.
If user enters LastName, then FirstName is required.
I can get LastName textbox to autopostback, but how do I create a sub that
will capture the autopostback and then enable the requiredFieldValidator.
I have many textboxes in the database so I need something that is generic?
thanks


 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      03-29-2005
"=?Utf-8?B?TFU=?=" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> If user enters LastName, then FirstName is required.
> I can get LastName textbox to autopostback, but how do I create a sub
> that will capture the autopostback and then enable the
> requiredFieldValidator. I have many textboxes in the database so I
> need something that is generic?


Why don't you bind the requirefieldvalidator when you created it the
first time?

So your loop:

Create Control
Create Validator
Bind Validator to Control

On postback:
Check validators
Valid
Continue
Else
Display Current Page


--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
 
 
 
=?Utf-8?B?TFU=?=
Guest
Posts: n/a
 
      03-29-2005
I do bind when i create them.
Loop
Create textbox.id = 1
Create requiredValidator.id = "req"&1
requiredValidator.controlToValidate = 1
requiredValidator.enabled = false

I set enabled to false because the FirstName is not required UNLESS you you
enter text into the LastName field. LastName is not required at all. In my
example you can leave both first name and last name empty, but if you enter a
last name, then you must enter a first name.
So, I have lastname autopostback, (I can't figure out how to capture the
autopost back to enable the fistname validator).
Next,
In my example I use FirstName and LastName, but in my database I have
something like pub0, pub1, pub2, pub3, pub4
so I wanted something generic to capture the postback, then I can strip the
string, get the number, then enable the corresponding, requiredFieldValidator.

"Lucas Tam" wrote:

> "=?Utf-8?B?TFU=?=" <(E-Mail Removed)> wrote in
> news:(E-Mail Removed):
>
> > If user enters LastName, then FirstName is required.
> > I can get LastName textbox to autopostback, but how do I create a sub
> > that will capture the autopostback and then enable the
> > requiredFieldValidator. I have many textboxes in the database so I
> > need something that is generic?

>
> Why don't you bind the requirefieldvalidator when you created it the
> first time?
>
> So your loop:
>
> Create Control
> Create Validator
> Bind Validator to Control
>
> On postback:
> Check validators
> Valid
> Continue
> Else
> Display Current Page
>
>
> --
> Lucas Tam ((E-Mail Removed))
> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/
>

 
Reply With Quote
 
Lucas Tam
Guest
Posts: n/a
 
      03-30-2005
"=?Utf-8?B?TFU=?=" <(E-Mail Removed)> wrote in
news:(E-Mail Removed):

> I set enabled to false because the FirstName is not required UNLESS
> you you enter text into the LastName field. LastName is not required
> at all. In my example you can leave both first name and last name
> empty, but if you enter a last name, then you must enter a first name.
>


Maybe you could use a custom validator? Write some sort of custom
validation routine that could your multiple cases.

--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autopost Back, FormView, and Textbox Focus TdarTdar ASP .Net Web Controls 6 11-07-2005 01:06 AM
Autopost back and Blank Page Tony Doyle ASP .Net 6 05-18-2005 01:53 PM
Problem with dropdown list and autopost Robin ASP .Net 0 02-01-2005 05:58 PM
AutoPost Back List Boxes Derek Martin ASP .Net 0 10-20-2004 04:21 PM
Radiobuttons and textbox with autopost Sean ASP .Net 1 08-06-2003 12:32 AM



Advertisments