Control is set to false, jQuery selector fails

Posted by Damien Joe on Stack Overflow See other posts from Stack Overflow or by Damien Joe
Published on 2010-12-27T09:45:54Z Indexed on 2010/12/27 9:54 UTC
Read the original article Hit count: 178

Filed under:
|
|

Hi I have some controls on an asp.net modal which I show manually via code behind. Now I am trying to attach a selector on one of the controls inside pageLoad(), problem being is that the modal container is initially set to visible=false.

I tried checking for length but it still throws exception

if ($('#<%= myControl.ClientId %>').length > 0)
{
    $('#<%= myControl.ClientID %>').click(function() {
        // Do work
    });
} 

Compiler Error Message: CS0103: The name 'myControl' does not exist in the current context

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about jQuery