473,785 Members | 3,417 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically creating controls, validators, using autopost back

LU
I query database,
QuestionID | QuestionName | QuestionType
1 | FirstName | TextBox
2 | LastName | TextBox

Loop
Create TextBox
Create RequiredFieldVa lidator

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 requiredFieldVa lidator.
I have many textboxes in the database so I need something that is generic?
thanks
Nov 19 '05 #1
3 1169
"=?Utf-8?B?TFU=?=" <LU@discussions .microsoft.com> wrote in
news:10******** *************** ***********@mic rosoft.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
requiredFieldVa lidator. I have many textboxes in the database so I
need something that is generic?


Why don't you bind the requirefieldval idator 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********@rog ers.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 requiredValidat or.id = "req"&1
requiredValidat or.controlToVal idate = 1
requiredValidat or.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, requiredFieldVa lidator.

"Lucas Tam" wrote:
"=?Utf-8?B?TFU=?=" <LU@discussions .microsoft.com> wrote in
news:10******** *************** ***********@mic rosoft.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
requiredFieldVa lidator. I have many textboxes in the database so I
need something that is generic?


Why don't you bind the requirefieldval idator 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********@rog ers.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******** *************** ***********@mic rosoft.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********@rog ers.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
6485
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 been filled out correctly. If so, I need to update a database, and do other things. In order to check if the form is ok, I've tried looping through the validator controls, and I've also tried using page.isvalid.
2
2545
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 RequiredValidator() Dim vs as ValidationSummary = new ValidationSummary() RequiredValidator.ControlToValidate = "id of form control here" RequiredValidator.Enabled = True RequiredValidator.EnableClientScript = True RequiredValidator.ErrorMessage = "Test...
4
3611
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. This is working fine, and I can add a control (TextBox or DropDownList) dynamically for the user to fill in a value. This works well for just adding controls for data entry. Now, I want to add validators on the fly as well and it not going quite...
2
4571
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 easy, but 1) How do I set about dynamically creating user controls (like TextBox, TextArea) --- simply Declare and initialised (new) the user controls?? How do I "place" it graphically on the form. Ideally, I want them to lay out in a table, one...
1
2065
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 dynamically, for some of the inserted controls. The controls (e.g., textBoxes) get created correctly and viewstate is maintained across postbacks, etc - BUT there is an issue with the validation controls. The validation controls, themselves are...
1
1454
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 being bound to a label and the Values being bound to a DropDownList. All works fine. The next thing I wished to do was tap into the ItemDataBound event to add a generic "Please Select..." item to each DropDownList, with a value of "0". From...
3
2544
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 controls are not present nor their valves in Request.Form.AllKeys.
4
2976
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 while and it seems it's not possible because the row that gets added with each click won't get recreated after a post back. After all the reading it seems that any dynamically created controls must be created in the Init event to be recreated after...
1
4913
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 set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.