473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

dynamically creating controls, validators, using autopost back

LU
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
Nov 19 '05 #1
3 1157
"=?Utf-8?B?TFU=?=" <LU@discussions.microsoft.com> wrote in
news:10**********************************@microsof t.com:
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 (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #2
LU
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=?=" <LU@discussions.microsoft.com> wrote in
news:10**********************************@microsof t.com:
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 (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 19 '05 #3
"=?Utf-8?B?TFU=?=" <LU@discussions.microsoft.com> wrote in
news:3E**********************************@microsof t.com:
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 (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christian H | last post by:
Based on the content in my database, I need to populate different form controls and validators, such as textbox, dropdownlist, requiredfieldvalidators , etc. Then I need to check if the form has...
2
by: -=Chris=- | last post by:
I'm developing a custom server control that will be rendering a form based on some input. I've tried creating custom validators in vb.net like so: Dim v1 as RequiredValidator = new...
4
by: MattB | last post by:
Hello. I'm creating a page to edit a person's record (name address, etc) using a DataGrid. I want the fields that can be edited to be created at runtime based on a list of columns in web.config....
2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
1
by: Jeffrey Todd | last post by:
I have successfully created functionality that mostly models what I'm trying to do - which is dynamically insert controls into a user control (ascx), and insert validation controls, also...
1
by: Chad Smith | last post by:
Hi. I have an asp.net web application written in C# which creates a datasource consisting of a Name and a list of permissable Values. This datasource is then bound to a simple repeater, the Name...
3
by: Dotnet Gruven | last post by:
I've built a WebForm with a Table added dynamically in Page_Load when IsPostBack is false. The table includes a couple of TextBoxes, RadioButtonLists and CheckboxLists. On postback, those...
4
by: mohaaron | last post by:
I can think of a lot of reasons why this might need to be done but as far as I can tell it's not possible. I've been looking for a way to add HtmlTableRows to a table using a button click for a...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.