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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:54:06+00:00 2026-05-20T18:54:06+00:00

I am creating a new project from the ground up. I have my web

  • 0

I am creating a new project from the ground up. I have my web application in this web application I have references set up to multiple class libraries.

In one of those libraries I have some general Javascript files (like jQuery) that I need to load in my web application’s mastersheet. I cannot seem to get at the Javascript.

How can I access that Javascript, located in a different class library, from my web application project?

Attached is a screen shot for better clarity.

enter image description here

Update:
Is there any way do achieve this without using ScriptManager?

  • 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-20T18:54:07+00:00Added an answer on May 20, 2026 at 6:54 pm

    If you are looking to get out of using the ScriptManager but still retain the ability to store libraries in your DLL, try the following:

    1. Make a custom control in the assembly where your javascript library resides.
    2. Use ClientScriptManager.GetWebResourceUrl()
    3. Add the control the head of your master page (or anywhere else you like)

    I’ve include a short example of how to achieve this.

    Custom Control in Mri.Controls

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web.UI;
    
    namespace Mri.Controls
    {
        public class ScriptLoader : Control
        {
            protected List<string> ScriptUrls;
    
            public ScriptLoader()
            {
                ScriptUrls = new List<string>();
            }
    
            // Have to add libraries here because cannot access the Page object from the Constructor
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
    
                AddScriptKey("Mri.Controls.Resources.Scripts.Libraries.jQuery.js");
            }
    
            public void AddScriptKey(string key)
            {
                //  Using the assembly location, find the WebResourceUrl
                var webResourceUrl = Page.ClientScript.GetWebResourceUrl(typeof(ScriptLoader), key);
                AddScriptUrl(webResourceUrl);
            }
    
            public void AddScriptUrl(string url)
            {
                //  Check to see if script already exists
                if (!ScriptUrls.Any(s => s.Equals(url)))
                    ScriptUrls.Add(url);
            }
    
            protected override void Render(HtmlTextWriter writer)
            {    
                //  Render the script tags
                foreach (var scriptUrl in ScriptUrls)
                {
                    writer.Write(string.Format("\n<script type=\"text/javascript\" src=\"{0}\"></script>", scriptUrl));
                }
            }
        }
    }
    

    Add a TagPrefix to your Web.config in your Web Application

    <pages>
        <controls>
            <add tagPrefix="mri" namespace="Mri.Controls" assembly="Mri.Controls"/>
        </controls>
      </pages>
    

    Sample Mastersheet

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Page Title</title>
        <mri:ScriptLoader id="scriptLoader" runat="server" />
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ContentPlaceHolder ID="cphBody" runat="server" />
        </form>
    </body>
    </html>
    

    I hope this was along the lines of what you were looking for.

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

Sidebar

Related Questions

Issue: When creating a new SilverLight Application Project from Visual Studio 2010, the SilverLight
When we're creating a new TFS project, we're looking to take areas from one
When creating a new project, i want this project to become available from a
When creating a new project in netbeans, if i select JAVA Desktop application, it
I'm creating a new app and I want to use some libraries like this:
I am in the process of designing a web application which will have multiple
After creating a new Silverlight application from the JetPack theme template that was installed,
When I'm creating new project with GWT plug in it creates a skeleton project
When creating a new WSPBuilder project or new WSPBuilder item in Visual Studio, you
When creating a new Java project in IntelliJ IDEA, the following directories and files

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.