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 7748051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:41:03+00:00 2026-06-01T10:41:03+00:00

I have a slight issue where I can’t seem to select a User Control

  • 0

I have a slight issue where I can’t seem to select a User Control ID using jquery. The User Control is a message panel which appears when an action happens. So when the page loads this message panel isn’t part of the page. It is only when the user interacts with the page i.e. add an image that the message panel shows with a message.

Page controls

<asp:Panel ID="pan_cntrls" runat="server">
   <asp:Button ID="btnAddNewImg" runat="server" Text="Add new image" OnClick="btnAddNewImg_Click"
       Visible="true" />
   <uc9:MessagePanel ID="messagepanel1" runat="server"></uc9:MessagePanel>
</asp:Panel>

Javascript

<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $("#PageContent_IMG1_messagepanel1_divMessageBox").click(function () {
            alert("handler called");
        });
   });

What firebug shows

<div class="errorBox confirmation" id="PageContent_IMG1_messagepanel1_divMessageBox" style="height: 50px;">

I can select other IDs using jquery but not this one. I should also point out that I am using a modalpopupextender on the page. So when I submit data the page is doing postback. I tried using delegate because the ID is added to the DOM after page load but its not working.

Any ideas?

Thanks

  • 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-06-01T10:41:05+00:00Added an answer on June 1, 2026 at 10:41 am

    Basically, the problem is that you’re adding the handler at $(document).ready. The divs don’t exist yet, so this call does nothing.

    You need to attach the click handler after the div hits the page. There are a couple of ways you can achieve this:

    1

    Use add_endRequest, so execute the document.ready code after async queries:

    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
        $("#PageContent_IMG1_messagepanel1_divMessageBox").click(function () {
            alert("handler called");
        });
    });
    

    or 2

    Explicitly make an addHandler function and cause it using an injection from asp.net:

    In JS:

    function addHandler (ctrlID) {
        $("#" + ctrlID).click(function () {
            alert("handler called");
        });
    };
    

    In ASP.Net:

    Use RegisterStartupScript to call the addHandler, passing the ClientID of the control that needs the handler adding. See here for info on RegisterStartupScript.

    The first of these options is less efficient than the second (as it will execute after all postbacks), but easier to implement.

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

Sidebar

Related Questions

First of all: I'm at Scala 2.8 I have a slight issue while using
im new to jQuery and have a slight issue with the following navigation: http://jsfiddle.net/6Dh8j/7/
Having a slight Javascript issue at the moment, I am hoping to have the
hey everyone, here is the site SEE BELOW I have a slight jquery problem
Just wondering if anyone can help me with this slight issue. I'm writing a
I have a slight issue with some code I'm writing if(parameter == 1) {
This seems fairly trivial but I can't seem to work it out I have
I have a slight issue that someone might be able to point me in
I have a slight issue with parsing data in an array from PHP to
I have a slight issue in my C# code in Asp.net when deleting a

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.