The techie in me RSS 2.0
 Wednesday, February 27, 2008

If you have used ASP.NET web controls and java script you must have faced the problem of getting control’s id in java script especially if you are using content place holders, repeaters etc. So when generating the html content ASP.NET generates a unique Id to uniquely identify the control on the webpage. This id is visible through the property control.ClientId. And use this clientId in your java script to reference the control. I came across this recently when I was reviewing a code, I found that the developer getting the source code (html) for the aspx from the browser and hard coding that in the java script. Good logic (it was inside a content place holder), but there is no guarantee that the id is going to be same. For example the id generated in IIS5.0 and IIS 6.0 may be different. So if you develop in IIS 5.0 and deploy in IIS 6.0 (which most of us do) you will be shown the weird javascript error ‘value is null’ J.

You will need to render the java script through code behind. See msdn documentation for how to use client scripting in ASP.NET pages.

Check here for documentation on control.ClientId

 

Rujith

 

Wednesday, February 27, 2008 1:23:33 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -

About me
Name : Rujith Anand Send mail to the author(s)
Archive
<February 2008>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
2425262728291
2345678
Blogs I read
Disclaimer

Disclaimer
Postings are provided as is with no warranties, and confer no rights. Opinions expressed here are my own delusions; my employers at best shake their heads and sigh, at worst repudiate the content with extreme prejudice, whenever it manages to appear on their radar.

© Copyright 2012
Rujith Anand

Statistics
Advertisement
All Content © 2012, Rujith Anand