473,661 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
"trialTextB ox".
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 2148
On May 29, 10:53 am, Shraddha <shraddhajosh.. .@gmail.comwrot e:
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
"trialTextB ox".
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
1405
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 that some validations are important on the client side, and I am thinking of writing some php validations for the server side. What types of functions are usually written on the server side? What types are usually written on the client side?
6
7735
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. Because I don't want a post-back, I added some javascript to do this However, using client-side JS, I cannot enable any controls that have been disabled by server-side code. If the control is initially enabled, I can disable/enable it client-side.
1
2673
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 the JavaScript function. The function copies the data into a server textbox control. Step 2: The user presses the VS generated "Step 2" button, which calls the
14
6291
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) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in ControlToValidate property in two ways as I mentioned. Please advise. Thanks!
7
1639
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 = document.createElement("input"); nameInput.setAttribute("id", "authorname");
0
929
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 validators. The button is rendered as : .... onclick="return ConfirmSave();if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " The if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); part is added by .NET...
7
3187
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 -- UC/ ----- Classic/
4
1395
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 by having the control hidden and grabbing it's innerHTML to a new container in the HTML. i also change controls ID suffix in order to be able to track added controls like in old HTML.
4
4475
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 selected, the row is added using JavaScript. The script uses cloneNode to clone a hidden template row and all of its children and then adds the new row to the table, updates all of the child control Ids and sets visibility etc. The hidden...
0
8855
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...
1
8545
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
7364
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
6185
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
5653
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
4179
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...
0
4346
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
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
1743
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.