Posts
33
Comments
135
Trackbacks
0
July 2013 Entries
Retrieve .Net Control ID in Javascript

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 %>"

Posted On Wednesday, July 24, 2013 6:22 PM | Comments (0)