Retrieve .Net Control ID in Javascript
Posted
by Vipin
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Vipin
Published on Wed, 24 Jul 2013 11:22:31 GMT
Indexed on
2013/08/02
15:40 UTC
Read the original article
Hit count: 258
Originally posted on: http://geekswithblogs.net/Vipin/archive/2013/07/24/retrieve-.net-control-id-in-javascript.aspx
If you need to retrieve a client ID of an asp:net control in a javascript function, then you can use the below function -
function $$(id, context) {
var el = $("#" + id, context);
if (el.length < 1)
el = $("[id$=_" + id + "]", context);
return el;
}
var tempDotNetControl = 'aspTextTemporary';
var ClientSideID = $$(aspTextTemporary);
Please bear in mind, this function is useful if you want to retrieve client ID of a different DotNet control based on some condition, otherwise if it’s always static then you can just use <%= aspTextTemporary.ClientID %>"
© Geeks with Blogs or respective owner