Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3612764
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:02:29+00:00 2026-05-18T22:02:29+00:00

Hi I have some controls on an asp.net modal which I show manually via

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T22:02:30+00:00Added an answer on May 18, 2026 at 10:02 pm

    A few things here, the first/main issue is that myControl isn’t defined in the current scope, wherever you are in ASP.Net, that’s entirely a .Net side problem.

    For the Script, there are more issues, .ClientID, not .ClientId. Also, there’s no need to check for it’s existence, you can just do:

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

    …if the control isn’t there, it just won’t find/bind anything. There’s also an easier way to go about it in ASP.Net, if there’s a unique class you can give it, just give add that class, e.g. CssClass="MyClass", then use that as your selector; like this:

    $('.MyClass').click(function(){
      // Do work
    });
    

    This allows you to put the script in an external file instead of the page as well, another benefit to the user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net mvc 3 application, and am now trying to add some
I have an ASP.NET page using the AJAX control toolkit for some controls. A
I have a ASP.NET Web Forms application and I'm using some dynamic controls in
I have an asp.net form that contains some html, 2 controls a calendar from
I have an ASP.NET MVC control which has to do some work to format
I have some user controls in ASP.NET that I am using as simply HTML,
I've been developing traditional ASP.NET applications with server side ASP.NET controls and code behind
I have a webpart with asp.net control within. I would like to hide some
I have an Asp.Net 4.0 website/control interface that uses an update panel and some
I have a series of controls on an ASP page. Some are inside an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.