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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:14:17+00:00 2026-05-26T03:14:17+00:00

I have a jqueryscript that works with asp.net pages without masterpages. When the page

  • 0

I have a jqueryscript that works with asp.net pages without masterpages. When the page gets an reference to a masterpage the script stop working.

The masterpage:
Within the header:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>

At codebehind:

protected void Page_Load(object sender, EventArgs e)
    {
        string script = "$(document).ready(function () { $(\"img[src*='help']\").click(function () { var id = $(this).attr(\"id\"); $(\"#helpviewer\").toggle(400); $(\"#helpviewer\").load(\"" + Page.ResolveUrl("~/help/help.aspx") + " \" + \"#\" + id); return false; }); });";
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script, true);
    }

Here is the helppage that jquery loads:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="help.aspx.cs" Inherits="help_help" meta:resourcekey="PageResource1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    </head>

    <body>
        <form id="form1" runat="server">
            <div id="helpUploadFile">
                <asp:literal id="Literal1" runat="server" meta:resourcekey="Literal1Resource1"></asp:literal>
            </div>
            <div id="helpPictureArchive">
                <asp:literal id="Literal2" runat="server" meta:resourcekey="Literal2Resource1"></asp:literal>
            </div>
            <div id="image1">
                <asp:literal id="Literal3" runat="server" meta:resourcekey="Literal3Resource1"></asp:literal>
            </div>
        </form>
    </body>
</html>

I belive my problem lies in the .load. The script is working, the helpviewer is shown up but the text is not loading.

Here is a working testpage without masterpage. and here is a testpage with the masterpage. Just click at the image to se the jquery.

Any idea whats wrong?

  • 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-26T03:14:18+00:00Added an answer on May 26, 2026 at 3:14 am

    IDs in master pages (or any other container) get mangled due to the way naming containers work, so I like to reference my server controls using jQuery’s ends with selector:

    $("[id$='MyControlName']");
    

    Since the mangled IDs always have the control name on the right, this just works. The mangled ID would look something like this: MasterPage1_ctl02_MyControlName

    I’ve seen some people criticize this approach as relatively slow compared to concatenating in Control.ClientID, which is how I used to do it. But avoiding Control.ClientID means you can store your JavaScript in a seperate file, which is a best practice. Sometimes, if you’re getting extremely dynamic, doing JS on the server is unavoidable. But in a seperate file you’ve got better seperation of concerns, and Visual Studio gives you some intellisense, and so on.

    Here’s a related question: jQuery Selector: Id Ends With?

    More about naming containers: MSDN Article

    • 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 page that executes a jquery script on load. The
Please refer to this page for reference: http://loadedgranola.valitics.com/_product_83484/blackberry_lime I have a jQuery script that
I have a datalist being generated with ASP, but unfortunately the jQuery script that
so I have this jQuery script below that works. But since I'm just learning
I need some help with my jQuery script. I have a page that refreshes
I have a custom jQuery script that works fine in all bowsers but one
I have a jQuery script that works perfectly fine in Chrome 11 and Firefox
I have a simple show/hide jquery script that works fine on its own, The
I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
I have an ASP.net MVC2 application. In wich I'm using JQuery to alter all

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.