472,958 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Experts Can you help me solve this dynamic textbox validation prob

Kum
Hi,
I need help in asp.net dynamic textbox controls
validation.

I am creating textbox controls dynamically on a
asp.net webpage. Now after creating the textboxes on
the page I want to validate these text boxes when the
user submits or posts back to the server. My intention
was to create a textboxvalidator function which takes
the control name as argument and returns an true if
valid else the corresponding error message. The
situation is complex as the multiple textboxes
dynamically generated will have different data types.

Scenario:

1. User opens a webpage and selects a number in a
dropdownbox and submits
2. Depending on the number selected, correspondingly
dynamic textboxes are generated with id textbox1,
textbox2, etc and shows up on the webpage.
3. User then fills the textbox1,
textbox2,etc...textbox30...
4. Now I need to check the values entered in textbox1,
textbox2, etc..
5. The textbox1 should be valid date, textbox2 should
be valid number, textbox3 should be valid email and so
on..

My solution could have been that I generate
customvalidation controls for each and every textbox
dynamically created and assign the control to be
validated as the corresponding textbox id. However, I
am not sure if that is a good approach. Because if the
user selects 50 we need to created 50 customvalidation
controls.

Rather i feel it would be better to write a common
validateDatetextbox(textboxcontrolid),
validateNumbertextbox(textboxcontrolid), etc functions
and pass the textbox id to this function to check the
validity of that textbox.

I am not sure which is the best approach and how I
proceed. I greatly appreciate if some one could send
me a sample code of how to do this.

Thanks in advance

Mike

Nov 19 '05 #1
1 1914
If I understand you correctly, you need a validator that confirms a real
date, integer, and email address have been entered. The ASP.NET validators
handle all of these cases without creating a custom control.
1. Use the CompareValidator to check the format of a date, integer, currency
and decimal. Set the Operator property to DataTypeCheck and Type property as
needed.
2. Use the RegularExpressionValidator for emails and other strongly
patterned strings. In fact, the ValidationExpression property has a cool
editor in the Properties Editor that lists common expressions including the
email address expression.

Now if you are trying to intelligently enable the validators based on the
DropDownList, you can simply change the Enabled property on the server-side.
It sounds like they are disabled initially (Enabled=false).

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Kum" <Ku*@discussions.microsoft.com> wrote in message
news:41**********************************@microsof t.com...
Hi,
I need help in asp.net dynamic textbox controls
validation.

I am creating textbox controls dynamically on a
asp.net webpage. Now after creating the textboxes on
the page I want to validate these text boxes when the
user submits or posts back to the server. My intention
was to create a textboxvalidator function which takes
the control name as argument and returns an true if
valid else the corresponding error message. The
situation is complex as the multiple textboxes
dynamically generated will have different data types.

Scenario:

1. User opens a webpage and selects a number in a
dropdownbox and submits
2. Depending on the number selected, correspondingly
dynamic textboxes are generated with id textbox1,
textbox2, etc and shows up on the webpage.
3. User then fills the textbox1,
textbox2,etc...textbox30...
4. Now I need to check the values entered in textbox1,
textbox2, etc..
5. The textbox1 should be valid date, textbox2 should
be valid number, textbox3 should be valid email and so
on..

My solution could have been that I generate
customvalidation controls for each and every textbox
dynamically created and assign the control to be
validated as the corresponding textbox id. However, I
am not sure if that is a good approach. Because if the
user selects 50 we need to created 50 customvalidation
controls.

Rather i feel it would be better to write a common
validateDatetextbox(textboxcontrolid),
validateNumbertextbox(textboxcontrolid), etc functions
and pass the textbox id to this function to check the
validity of that textbox.

I am not sure which is the best approach and how I
proceed. I greatly appreciate if some one could send
me a sample code of how to do this.

Thanks in advance

Mike

Nov 19 '05 #2

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

Similar topics

1
by: sleigh | last post by:
Hello, I'm building a web application that will build a dynamic form based upon questions in a database. This form will have several different sections that consist of a panel containing one to...
6
by: dhnriverside | last post by:
Hi peeps, I'm trying to create some controls textboxes at runtime, based on the number of items in a IETreeView that are checked. That I can do, I've got a place holder and I can create the...
1
by: Nathan Sokalski | last post by:
When testing a form of mine which uses RequiredFieldValidators that have the Display property set to "Dynamic" the ErrorMessage property is automatically removed when an entry is completely typed...
0
by: Steve Funk | last post by:
All, I have searched all around and have not yet found the answer to this nor a solution. Hopfully it will be easy to overcome. Here is what I am trying to do: I'm trying to build a wizard...
0
by: Mike Collins | last post by:
I have a form where I create dynamic controls at runtime. With this, I am adding a dynamic required field validators to each control as needed, but the validators are not firing when I click...
2
by: Christina | last post by:
Hello !! I am creating a dynamic textbox and want to validate it using the requiredfieldvalidator. These are the steps which I tried: ==================================================== 1)...
2
by: Mike Collins | last post by:
I have a form where I create dynamic controls at runtime. With this, I am adding a dynamic required field validator to each control as needed, but the validators are not firing when I click submit....
3
by: Mukesh | last post by:
sir, i am developing a database, which will store the users profile both personal and professional which includes the address, telephone, gender and etc. in my main table i have created a column...
2
by: =?Utf-8?B?SmVycnkgSg==?= | last post by:
Hello, I am using asp.net 2003 using C#. I am creating textboxes dynamically and want to validate to make sure the user can only input an integer. I don't think I can use the validators...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.