Google
 
Webnews.only-4-geeks.com
Interesting places
news.only-4-geeks.com Forum Index » JavaScript

Client side validations for dynamically added user control

 
Jump to:  
 
Shraddha
PostPosted: Thu May 29, 2008 1:53 pm    Post subject: 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.
 

 
Thiago Macedo
PostPosted: Thu May 29, 2008 2:58 pm    Post subject: Re: Client side validations for dynamically added user contr
       
On May 29, 10:53 am, Shraddha <shraddhajosh...@gmail.com> wrote:
Quote:
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
 

Page 1 of 1 .:.

Google
 
Webnews.only-4-geeks.com

Windows Update | C++ | C | PHP | JavaScript | Photoshop | Programming | Windows 2000 | Python | Windows XP | Object | Flash | Flash - ActionScript | Paint Shop Pro | Excel | PowerPoint | Access | Word | Windows 98 | Internet Explorer 6.0 | CorelDraw12 | Java | XML | asm x86 | Linux Mandrake | Linux RedHat | Outlook |  | news from newsgroups |_ | s

Web Templates

Awesome Website Templates ©

zbior Angielski opisy na gg Odzyskiwanie danych Teksty piosenek