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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:51:59+00:00 2026-05-14T21:51:59+00:00

I’m looking to create a wrapper control for JQuery date time picker control to

  • 0

I’m looking to create a wrapper control for JQuery date time picker control to be used in asp.net website. Once the user control is ready, it will be used in simple web forms / grids / data lists or repeater controls. User control will also expose below mentioned properties for customization.

  1. TimeHourFormat: “12” or “24” (12 (AM/PM) or 24 hour)
  2. TimeAMPMCondense: True (If 12 hour format, display AM/PM with only 1 letter and no space i.e. 1:00A or 5:05P)
  3. TimeFormat: “HH/MM” (Leading zeros on Hours and Minutes. Default to always have leading zeros.)
  4. CssClass: “calendarClass” (Name of the CSS class/style sheet for formatting)
  5. ReadOnly: True (Set textbox to readonly mode and disable pop up calendar If false, then enable pop up calendar and enable access to textbox)
  6. DateFormat: “MM/DD/YYYY” (Pass C# standard formatting to also include YY no century formats. Default to always have leading zeros and century.)
  7. Display: “C” (Pass C to display Calendar only, CT for Calendar and Time, and T for time only display)
  8. Placement: “Popup” (Default for pop up of the control, could also be inline)
  9. DateEarly: “01/01/1900” (If date is equal to or less than, then display and return a null (blank) value)
  10. WeekStart: “Sun” (Day of week to start calendar)
  11. Image: “/image/calendar.ico” (Name and path to use for the image used on the right of the textbox to click and have it display. If not specified, then clicking in the enabled field will ‘pop up’ the control.)

Follow the JQuery Date Time Picker Implementation. See Demo in action.

I’m open for any idea or suggestion. Feel free to comment or share your ideas.

Thanks in advance.

  • 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-14T21:52:00+00:00Added an answer on May 14, 2026 at 9:52 pm

    I take it you want to create a re-useable control that uses jQuery functionality and wraps everything up nicely? If I’ve understood you correctly you need to create an IScriptControl.

    Create two files in your project, i.e:

    Project
    |...Controls
        |...MyDateTimePicker.cs
        |...MyDateTimePicker.js
    

    Set MyDateTimePicker.js as an embedded resource and then add the following line to your assembly info:

    [assembly: System.Web.UI.WebResource("Project.Controls.MyDateTimePicker.js", "text/javascript")]
    

    Once you’ve done that, go to the MyDateTimePicker.cs class and create a basic template as follows:

    [DefaultProperty("ID")]
    [ToolboxData("<{0}:MyDateTimePicker runat=server />")]
    public class MyDateTimePicker : WebControl, IScriptControl
    {
    
    }
    

    Once you’ve done that, you need to register the control as a ScriptControl, so add the following:

    protected override void OnPreRender(EventArgs e)
    {
    
        if (!this.DesignMode)
        {
    
            // Link the script up with the script manager
            ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
            if (scriptManager != null)
            {
                scriptManager.RegisterScriptControl(this);
                scriptManager.RegisterScriptDescriptors(this);
                scriptManager.Scripts.Add(new ScriptReference(
                    "Project.Controls.MyDateTimePicker.js", "Project"));
            }
            else
            {
                throw new ApplicationException("You must have a ScriptManager on the Page.");
            }
    
        }
    
        base.OnPreRender(e);
    
    }
    

    This now means that the control can pass properties client side. So, start by adding your properties, i.e.

    public virtual string TimeHourFormat {get;set;}
    public virtual string TimeFormat {get;set;}
    

    Once you have some properties you need to pass them as script descriptors:

    IEnumerable<ScriptDescriptor> IScriptControl.GetScriptDescriptors()
    {
        ScriptControlDescriptor desc = new ScriptControlDescriptor("Project.MyDateTimePicker", 
            this.ClientID);
    
        // Properties
        desc.AddProperty("timeHourFormat", this.TimeHourFormat);
        desc.AddProperty("timeFormat", this.TimeFormat);
    
        yield return desc;
    }
    
    IEnumerable<ScriptReference> IScriptControl.GetScriptReferences()
    {
        ScriptReference reference = new ScriptReference();
        reference.Assembly = Assembly.GetAssembly(typeof(MyDateTimePicker)).FullName;
        reference.Name = "Project.MyDateTimePicker.js";
        yield return reference;
    }
    

    We now have everything we need to implement the client side script, which can contain all the jQuery you want. Pop the following template into MyDateTimePicker.js and away you go!

    Type.registerNamespace('Project');
    
    Project.MyDateTimePicker = function (element) {
    
        this._timeHourFormat = null;
        this._timeFormat = null;
    
        // Calling the base class constructor
        Project.MyDateTimePicker.initializeBase(this, [element]);
    
    }
    
    Project.MyDateTimePicker.prototype =
    {
    
        initialize: function () {
    
            // Call the base initialize method
            Project.MyDateTimePicker.callBaseMethod(this, 'initialize');
    
            $(document).ready(
                // See, jQuery!
            );
    
        },
    
        dispose: function () {
    
            // Call the base class method
            Project.MyDateTimePicker.callBaseMethod(this, 'dispose');
    
        },
    
    
        //////////////////
        // Public Methods 
        ////////////////// 
    
        // Hides the control from view
        doSomething: function (e) {
    
        },
    
        //////////////////
        // Properties 
        //////////////////   
    
        get_timeHourFormat: function () {
            return this._timeHourFormat;
        },
        set_timeHourFormat: function (value) {
            var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
            if (e) throw e;
            if (this._timeHourFormat != value) {
                this._timeHourFormat = value;
                this.raisePropertyChanged('timeHourFormat');
            }
        },
    
        get_timeFormat: function () {
            return this._timeFormat;
        },
        set_timeFormat: function (value) {
            var e = Function._validateParams(arguments, [{ name: 'value', type: String}]);
            if (e) throw e;
            if (this._timeFormat != value) {
                this._timeFormat = value;
                this.raisePropertyChanged('timeFormat');
            }
        }
    
    }
    
    
    Project.MyDateTimePicker.registerClass('Project.MyDateTimePicker', Sys.UI.Control);
    
    if (typeof(Sys) != 'undefined')
    {
        Sys.Application.notifyScriptLoaded();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 445k
  • Answers 445k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Why not use the 'Copy local' for first use, and… May 15, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer It depends on several things. Is there any reason to… May 15, 2026 at 6:55 pm
  • Editorial Team
    Editorial Team added an answer On Windows the function is VirtualProtect, you'll want to pass… May 15, 2026 at 6:55 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.