Tuesday, February 28, 2012

Find a control from asp.net

If your controls are server generated, then sometimes, the name of the control changes,

I had this issue with a custom control.

 

this below code solves the problem.

 

    var naviDiv = document.getElementById('<%=mainSpan.ClientID%>');

 

    if (isInIFrame) {

        naviDiv.style.display = "none";

    }

 

 

Side note: the JS must exist AFTER the <div> else it reports that the div does not exist!

No comments: