473,800 Members | 2,380 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 6479
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
5338
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
1965
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
1321
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
1309
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
9369
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
35688
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
2290
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
9551
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,...
1
10253
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
10033
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
9085
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...
1
7576
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6811
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
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4149
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
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.