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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:02:55+00:00 2026-05-14T18:02:55+00:00

I have build a custom Html Helper extension as follows: public static string DatePicker(this

  • 0

I have build a custom Html Helper extension as follows:

public static string DatePicker(this HtmlHelper helper, string name, string value)
{
        return string.Format(@"<script type='text/javascript'>
$(document).ready(function(){{
    $('#{0}').datepicker({{ 
        changeMonth: true, 
        changeYear:true, 
        dateFormat: 'd-M-yy', 
        firstDay: 1, showButtonPanel: 
        true, 
        showWeek: true 
    }});
}});
</script>
<input type='text' name='{0}' id='{0}' value='{1}'>", name, value);
}

The problem is that this now requires the page to “include” the following:

<script src="/Scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="/Scripts/jquery.ui.datepicker.min.js" type="text/javascript"></script>

And a few other items. The questions are as follows:

  1. Is there a serious processing
    overhead if I were to include these
    items in EVERY page (like in the
    Site.Master for example) thus
    negating the need for the HtmlHelper
    to organise the “includes” –
    considering there would end up being
    about 20 includes for all the
    different types of jQuery UI widgets
    used throughout the site.

  2. If the HtmlHelper sorts out the
    “includes”, it will add one every
    time this DatePicker is used (often
    there are two on a page) Does anyone
    have a way of determining whether or
    not the user has already rendered
    the same type of control on the
    page, thus not re-including the same
    jquery libraries when multiple
    instances of the DatePicker (for
    example) are used?

  • 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-14T18:02:55+00:00Added an answer on May 14, 2026 at 6:02 pm

    Maybe something of these code pieces will help you to get an idea or two about it:

    private static readonly SortedList<int, string> _registeredScriptIncludes = new SortedList<int, string>();
    
        public static void RegisterScriptInclude(this HtmlHelper htmlhelper, string script)
        {
            if (!_registeredScriptIncludes.ContainsValue(script))
            {
                _registeredScriptIncludes.Add(_registeredScriptIncludes.Count, script);
            }
        }
    
        public static string RenderScript(this HtmlHelper htmlhelper, string script)
        {
            var scripts = new StringBuilder();
            scripts.AppendLine("<script src='" + script + "' type='text/javascript'></script>");
            return scripts.ToString();
        }
    
        public static string RenderScripts(this HtmlHelper htmlhelper)
        {
            var scripts = new StringBuilder();
            scripts.AppendLine("<!-- Rendering registered script includes -->");
            foreach (string script in _registeredScriptIncludes.Values)
            {
                scripts.AppendLine("<script src='" + script + "' type='text/javascript'></script>");
            }
            return scripts.ToString();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going to have to build a custom control for a WinForms application. But
I have three custom build configurations { Dev, Qs, Prd }. So, I have
I have inherited a visual studio 2003 project which uses some custom build steps.
We have a custom navigation webpart that uses the PortalSiteMapProvider of MOSS to build
I have a problem: I need to build a custom tag, which can take
I have a custom built ajax [div] based dynamic dropdown. I have an [input]
We have a custom-built Flash-based video player that I maintain, and it needs to
I have a custom application that was built to send opt-in newsletters and marketing
I have a mac with a custom PHP 5 install that built from about
I currently have a custom session handler class which simply builds on php's session

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.