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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:22:26+00:00 2026-05-15T18:22:26+00:00

Our web application started out as a big, honkin’ ASP.NET AJAX ‘page’ with oodles

  • 0

Our web application started out as a big, honkin’ ASP.NET AJAX ‘page’ with oodles of controls on it. They all shared a small set of large .js and .css files. I need to use some of these controls in other, unrelated pages around our site. The difficulty is in all the other stuff the .css and .js files bring along with them when I try to use those controls elsewhere – too much and there’s a lot of bloat, too little and the controls don’t work.

So, I’ve been experimenting with breaking up the .css and .js and writing the controls to register the .js and .css they need. Initially I will end up with many more but smaller .js and .css files, but I can combine them at run-time later. I just want to encapsulate these controls so the pages that use them know less about what it takes to use them.

But I am running into a problem. I am using OnInit or OnLoad to register the .css and .js as needed. Unfortunately, none of these methods is called if the control is not visible the first time you hit the page when all the .css and .js needs to make its way to the client. It isn’t until later on that the controls are enabled for thier specific functions that they are visible and could emit the .js or .css. Then it’s too late!

Do I have to bite the bullet and hand-include the right .css/.js on the pages I use these controls on, or is there a better way to ‘inventory’ the controls in use to get them to emit what they need?

  • 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-15T18:22:26+00:00Added an answer on May 15, 2026 at 6:22 pm

    I assume that the problem you are facing is that some controls are loaded dynamically (i.e. in an update panel). It is a tricky problem – usually because you don’t know in advance what controls you will need and thus what JS + CSS to include.

    Perhaps you should consider loading the JS and CSS dynamically using a script loader?
    The YUI script loader and the new MS one spring to mind (but I am sure that there are dozens of other equally good ones out there).

    See this previous answer for a couple of potentially useful links. Also see here for more about the MS script loader and YUI scriptloader.

    Being that you are already using MS stuff I would recommend the MS script loader but as far as I know, the MS script loader does not support managing your dynamically loaded CSS (if anyone knows different please correct me) and so maybe the YUI solution might be more suitable (or maybe you can roll your own way of dynamically adding CSS if it has not already been added – it shouldn’t be too hard).

    Using a script loader removes the headache of working out up front what you need to include but it may require some changes to your javascript. In particular, if you have any javascript inline in your control’s markup that relies on functions declared in the javascript you are dynamically adding.

    E.g. If you current have user control markup like this

      <div id="my control">
        <script type="text/javascript>
          foo(); // foo is defined in foo.js, which is included in a script element in the head
          ... more script ...
        </script>
        ....
      </div>
    

    Then using a script loader you must change it to look like this

      <div id="my control">
    
        <script type="text/javascript>
          var onLoadHandler = function() {
            foo();
            ... more script ...
          };
          Sys.loader.registerScript("foo_package_name", null, onLoadHandler); 
        </script>
      </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day, We just converted our web application .NET 1.1 to .NET 2.0. We
our web application frequently losses it's session state (user is being logged out very
Our web application renders fast in some IE browsers, slow in others... It seems
Our web application sends e-mails. We have lots of users, and we get lots
On our web application, the search results are displayed in sortable tables. The user
In our web application we have a directory which resides outside of the project.
we need reports in our web application and there is the free ReportViewer Control
To facilitate uploading on our web application we install/load an ActiveX control on the
We are finishing up our web application and planning for deployment. Very important aspect
We have the usual web.xml for our web application which includes some jsp and

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.