473,788 Members | 2,855 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help!! Dynamic Textbox, validation requiredFieldVa lidator

Hello !!

I am creating a dynamic textbox and want to validate it using the
requiredfieldva lidator.

These are the steps which I tried:
=============== =============== =============== =======
1) In Page_load,

Dim Email As New Label
Email.Text = "* Email Address"
placeHolder1.Co ntrols.Add(Emai l)

Dim txtEmailAddress As New TextBox
placeHolder2.Co ntrols.Add(txtE mailAddress )
2) The HTML has:
<tr><td>
<asp:PlaceHolde r ID="placeHolder 1" Runat="server"> </asp:PlaceHolder >
<asp:requiredfi eldvalidator id="reqFieldVal 1" runat="server"
Display="Dynami c" ErrorMessage="R equired"
ControlToValida te="txtEmailAdd ress"></asp:requiredfie ldvalidator>
</td>
</tr>

=============== =============== =============== =======

This gives an error message :

Unable to find control id 'txtEmailAddres s' referenced by the
'ControlToValid ate' property of 'reqFieldVal1'.
I tried the following options, but was unsuccessful:

a) Move requiredFieldVa lidator inside placeholder. (Googling around,
suggested that the validator and control should be in the same
container)

b) Tried to create requiredFieldVa lidator dynamically and add it in the
same placeholder (ie placeHolder1)

Any pointers will be appreciated !!

TIA..

Nov 13 '06 #1
2 6478
RSH
Christina,

You have to set the ID property of the textbox. You are creating a textbox
object and then referring to it in code but from the perspective of the form
it has no ID so .Net is making and ID up which doesn't align with the name
you have given it.

Dim txtEmailAddress As New TextBox

txtEmailAddress .ID = "txtEmailAddres s" <---- Add this

PlaceHolder2.Co ntrols.Add(txtE mailAddress)

Dim ReqFieldVal As New RequiredFieldVa lidator

ReqFieldVal.Con trolToValidate = "txtEmailAddres s"

ReqFieldVal.Err orMessage = "Required"

PlaceHolder2.Co ntrols.Add(ReqF ieldVal)

HTH,

Ron

"Christina" <ch*********@gm ail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
Hello !!

I am creating a dynamic textbox and want to validate it using the
requiredfieldva lidator.

These are the steps which I tried:
=============== =============== =============== =======
1) In Page_load,

Dim Email As New Label
Email.Text = "* Email Address"
placeHolder1.Co ntrols.Add(Emai l)

Dim txtEmailAddress As New TextBox
placeHolder2.Co ntrols.Add(txtE mailAddress )
2) The HTML has:
<tr><td>
<asp:PlaceHolde r ID="placeHolder 1" Runat="server"> </asp:PlaceHolder >
<asp:requiredfi eldvalidator id="reqFieldVal 1" runat="server"
Display="Dynami c" ErrorMessage="R equired"
ControlToValida te="txtEmailAdd ress"></asp:requiredfie ldvalidator>
</td>
</tr>

=============== =============== =============== =======

This gives an error message :

Unable to find control id 'txtEmailAddres s' referenced by the
'ControlToValid ate' property of 'reqFieldVal1'.
I tried the following options, but was unsuccessful:

a) Move requiredFieldVa lidator inside placeholder. (Googling around,
suggested that the validator and control should be in the same
container)

b) Tried to create requiredFieldVa lidator dynamically and add it in the
same placeholder (ie placeHolder1)

Any pointers will be appreciated !!

TIA..

Nov 13 '06 #2
Thanks Ron !! It worked !!
I appreciate your quick response !!

RSH wrote:
Christina,

You have to set the ID property of the textbox. You are creating a textbox
object and then referring to it in code but from the perspective of the form
it has no ID so .Net is making and ID up which doesn't align with the name
you have given it.

Dim txtEmailAddress As New TextBox

txtEmailAddress .ID = "txtEmailAddres s" <---- Add this

PlaceHolder2.Co ntrols.Add(txtE mailAddress)

Dim ReqFieldVal As New RequiredFieldVa lidator

ReqFieldVal.Con trolToValidate = "txtEmailAddres s"

ReqFieldVal.Err orMessage = "Required"

PlaceHolder2.Co ntrols.Add(ReqF ieldVal)

HTH,

Ron

"Christina" <ch*********@gm ail.comwrote in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
Hello !!

I am creating a dynamic textbox and want to validate it using the
requiredfieldva lidator.

These are the steps which I tried:
=============== =============== =============== =======
1) In Page_load,

Dim Email As New Label
Email.Text = "* Email Address"
placeHolder1.Co ntrols.Add(Emai l)

Dim txtEmailAddress As New TextBox
placeHolder2.Co ntrols.Add(txtE mailAddress )
2) The HTML has:
<tr><td>
<asp:PlaceHolde r ID="placeHolder 1" Runat="server"> </asp:PlaceHolder >
<asp:requiredfi eldvalidator id="reqFieldVal 1" runat="server"
Display="Dynami c" ErrorMessage="R equired"
ControlToValida te="txtEmailAdd ress"></asp:requiredfie ldvalidator>
</td>
</tr>

=============== =============== =============== =======

This gives an error message :

Unable to find control id 'txtEmailAddres s' referenced by the
'ControlToValid ate' property of 'reqFieldVal1'.
I tried the following options, but was unsuccessful:

a) Move requiredFieldVa lidator inside placeholder. (Googling around,
suggested that the validator and control should be in the same
container)

b) Tried to create requiredFieldVa lidator dynamically and add it in the
same placeholder (ie placeHolder1)

Any pointers will be appreciated !!

TIA..
Nov 13 '06 #3

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

Similar topics

1
5336
by: Bryan | last post by:
I trying to figure out out to validate a textbox inside a repeater once a person presses a button on a repeater. Here's the validation Code behind: Please be aware that line e.Item.ItemIndex is invalid. Because I don't know how to pass the repeater as the object through the OnServerValidate Tag in the ASP.NET side. What I really need is to pull the ItemIndex from the actual repeater.
1
1964
by: Kum | last post by:
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
2
1320
by: zoneal | last post by:
Anyone can help me how to do dynamic textbox appearance? need it for matrix data entry, suppose i enter 3 and 4 then the 3x4 textboxes will appear.. thank you very much.
1
1308
by: Eugenio.Net | last post by:
Hello all I'm using a button to validade a TextBox but I already saw some websites that validation is automaticaly after 4 or 5 chars... How can I validate my textox to call a function??? Thanks in advanced for advices...
2
9368
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) In Page_load, Dim Email As New Label
1
1133
by: Madhumitham | last post by:
textbox validation (to enter numbers) in vb.net in both client side and server side
9
4035
by: kumarrk | last post by:
Hi all, i am using place holder for dynamic textbox and label box, then when i enter the values in textbox then i click the add button and save to database, but i couldnt get the dynamic textbox values, Pllssssssssss help how can i get the dynamic values using vb.net pls help me as soon as possible regards kumar thanxxx....
9
35685
mageswar005
by: mageswar005 | last post by:
Hi Guys, My array textbox validation is not working fine,my code is given below please help me immediately. function validation() { var chks = document.getElementsByName('rr');//here rr is the name of the textbox for (var i = 0; i < chks.length; i++) {
4
2289
by: marisenthil | last post by:
How to access the value of the dynamic textbox by its id? I created more dynamic textbox using the below in loop Dim tb As New TextBox tb.ID = "txt_" + Str$(i) and it assigned unique id. then how to access each textbox value by its id without using javascript.
0
9656
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
9498
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10370
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
10177
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...
0
9969
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
8995
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
6750
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();...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
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.