473,396 Members | 1,766 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,396 software developers and data experts.

Client side validations for dynamically added user control

Hi,
I am adding some ASP.Net user controls (.ascx file) dynamically on the
button click. The user control will get added as many times userhits
the button. Now on the click of the submit button, I want to do some
form level validations.

For example suppose my .ascx file contains a text box with id say
"trialTextBox".
Now if user hits the button thrice, 3 user controls will be there on
the page and as a result 3 textboxes mentioned above will be there.

Can any one tell me :

1) How can I get access to that user control (.ascx file) through the
java script? (While adding that user control I have given unique ids
to that user control).

2) If I get access to that user control, how can I access the controls
(Like text box mentioned earlier) and its values.

Any help or hint will be appreciated.
Jun 27 '08 #1
1 2127
On May 29, 10:53 am, Shraddha <shraddhajosh...@gmail.comwrote:
Hi,
I am adding some ASP.Net user controls (.ascx file) dynamically on the
button click. The user control will get added as many times userhits
the button. Now on the click of the submit button, I want to do some
form level validations.

For example suppose my .ascx file contains a text box with id say
"trialTextBox".
Now if user hits the button thrice, 3 user controls will be there on
the page and as a result 3 textboxes mentioned above will be there.

Can any one tell me :

1) How can I get access to that user control (.ascx file) through the
java script? (While adding that user control I have given unique ids
to that user control).

2) If I get access to that user control, how can I access the controls
(Like text box mentioned earlier) and its values.

Any help or hint will be appreciated.
Hello,

For start, you can't access the user control via JS. It's a server
side control which results in an HTML response. That response is what
you'll check with JavaScript.

There're many methods to such task. The first (and simpliest) I get in
mind is use the ClientId property of the txt control to get the
(unique) IDs of the textbox and then validate them with Javascript.
You could send it (the ids) to a hidden input, incrementing it
dynamically as the user adds the UsrCtr. With this hidden text field
populated with the unique ids of the text controls (comma separated or
whatever) loop (js) through them validating as you wish.

Hope this helps.

Thiago
Jun 27 '08 #2

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

Similar topics

4
by: byuedwin | last post by:
Hello, I am starting a new website, and I would like to decide ahead of time what functions (in JavaScript) I will need to write on the server side and which ones on the client side. I believe...
6
by: Stu Carter | last post by:
Hi, I have an aspx page where some controls are initially disabled by the code-behind 'Page_Load' event. I want these controls to be dynamically enabled when the user checks a checkbox. ...
1
by: Jim Hammond | last post by:
I can get data from a client-side assembly to the server in two manual steps, but I need to be able to do it in one step. Step 1: The user presses the manually coded "Step 1" button, which calls...
14
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
7
by: Quentin Huo | last post by:
Hi: I created a web-form user control. And in client-site, there is a link which will create a Input element object when it is clicked. <script language=javascript> ....... var nameInput =...
0
by: Pradeep Sundaram | last post by:
Hello, I have added an attribute "onclick" and a javascript to perform some tasks. The name of the function that needs to be called is say : confirmSave(); The problem is that the page also has...
7
by: Samuel | last post by:
Hi, I am building a page that makes use of user control as a templating technique. The following is that I have in mind and it is actually working: Root/ -- login.aspx -- login.aspx.vb --...
4
by: z f | last post by:
hi, tough one? for me it is currently. i have a user control that contains other controls like text boxes. in the client i need to dynamically add the user control using DHTML. i achive this...
4
by: Lewis Holmes | last post by:
Hi I have the following situation in one of my asp.net pages. The user can add multiple table rows to a form by selecting a button. These rows can contain asp.net controls. When this button is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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...
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...

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.