AspdotnetCodes.com
Voted 'Best ASP.NET Host' for 2008 – DiscountASP.NET
 
Articles Subscribe for our Articles Updates
Books
Resources
Downloads
Free Tech Magazines
Archives
Softwares
Newsletter
Suggest Us
Link to Us
 How to Use javascript in asp.net User Control
Posted by Prabhakaran on  2/14/2008 11:01:46 PM Category: ADO.NET
Add to my favorites
Email to friend
  
hi

how to use javascript events use in asp.net Usercontrols

Post Answer Post New Question

 Viewer's Answers
Use usual Javascript function in User Control
Posted By Moderator1 on 2/15/2008 7:54:34 PM
Description:
Hi,

You can write usual javascript functions in the Web User Control between the <script></script> tag. The only thing you have to consider is the name of the controls.

That is to get a value of a Textbox which id is 'TextBox1', you usually use like
document.getElementById('TextBox1').value

But this will not work at all times. That is the client id may change in some situation. Better you can use the below syntax to overcome that situation.

document.getElementById('<%=TextBox1.ClientID%>').value

Thanks
 
Sponsored by