Posts
33
Comments
186
Trackbacks
0
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 Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Comment *  
Verification