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

  • Home
  • SEARCH
  • 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 7859003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:43:30+00:00 2026-06-02T21:43:30+00:00

Consider the following situation: There is a master page with a contentPlaceHolder for all

  • 0

Consider the following situation:

There is a master page with a contentPlaceHolder for all javascript…

for speed issuses this section is at the bottom of the page.

my user control generates some javascript that make use of some references in the master page javascript (Jquery library)

so, if my user control is rendered before the master page javascript, it won’t work.

and this is my question:

how do I make some javascript code block inside my .ascx file to be rendered to the asp:Content JavaScript in the .aspx page

or maybe my all thinking is worng?

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-02T21:43:32+00:00Added an answer on June 2, 2026 at 9:43 pm

    See if this works for you:

    Where in the “bottom” of the Master Page? If you move it inside the closing server-side form control and use ClientScript.RegisterStartupScript in your user control, it will inject that script of your control “before the closing <form/> tag” (which will be after your your static script call).

    Master Page – right above the closing server-side ASP.Net </form>:

    ....
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js "></script>
    </form>
    

    Content Page (nothing special):

    <%@ Register src= ....
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
        <uc1:jscript_inject ID="jscript_inject1" runat="server" />
    </asp:Content>
    

    User Control:

    protected void Page_Load(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "foo", @"alert('foo');", true);
    
    }
    

    This is how its rendered (HTML view source in browser):

    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js "></script>
    
    <script type="text/javascript">
        //<![CDATA[
        alert('foo');//]]>
    </script>
    ....
    </form>
    

    As advertised, alert('foo'); is below the “pre-defined” jq cdn call….

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

Sidebar

Related Questions

Consider following situation: there is ComboBox and a filter TextBox, then user types a
Consider the following situation: There is an xml that contains data @XmlData The @XmlData
Consider the following situation: There is a serialization file, created by the older version
Lets consider the following situation. There is products_controller which can be accessed from Admin
Consider the following situation Code was added to the trunk at revision x A
Consider the following situation: WidgetCompany produced a .NET DLL in 2006 called Widget.dll, version
Consider the following situation: We have two Localizable.string files, one in en.lproj and one
Consider the following situation: I have two android projects named P1 and P2 which
Consider following make: all: a b a: echo a exit 1 b: echo b
consider following: 1st APPROACH: public void f3() { f2(); f1(); } and this ...

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.