ASP.NET - How to add date picker control

Asked By Rohini Kuchadi
25-Oct-11 03:46 AM
I have designed one application form in asp.net.In that field,i have one field Kit_Receive_date.For this field how can i add date picker control for this field
  dipa ahuja replied to Rohini Kuchadi
25-Oct-11 03:54 AM
Jquery
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>  
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js"></script>  
<link href="fbox/jquery-ui-1.8.11.custom.css" rel="stylesheet" type="text/css" />
<script src="fbox/jquery.ui.datetimepicker.min.js" type="text/javascript"></script>
  
<script type="text/javascript">
  $(function () {
  $('#TextBox1').datetimepicker();
  });
</script>
<input type="text" id="TextBox1" />

OUTPUT:

AJAX
<asp:TextBox ID="TextBox1" runat="server" />
 
<cc1:CalendarExtender  ID="TextBox1_CalendarExtender" runat="server" Enabled="True"
Format="yyyy-MM-dd" DefaultView="Years" TargetControlID="TextBox1">
 
  Vickey F replied to Rohini Kuchadi
25-Oct-11 04:24 AM

For binding calendar control with TextBox, Use JQuery Calendar Control.


For that you have to use JqueyUi plugin in your website, after that you can use Jquery calaendar Control.

Like this-


function funShowCal() {

$("#<%=txtDOB.ClientID%>").datepicker({

changeMonth: true,

changeYear: true

});

};


Here txtDOB is Server side TextBox Control.

For more detail follow this link-

http://jqueryui.com/demos/datepicker/


Here you will get working example.

  smr replied to Rohini Kuchadi
25-Oct-11 04:25 AM
hi

try this

Here We Go
 
Using visual Studio 2008 click on file then New then choose Project. Under web menu choose ASP.NET Server Control and name the project DatePicker.
 
vsgui Now we will change this control inheritance form WebControl to a CompositeControl. We will rename the toolboxdata and also will give the name to control with a default prefix showing as below
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.Web Controls;
 
[assembly: TagPrefix("DatePicker", "SQ")]
namespace DatePicker
{
 [DefaultProperty("Text")]
 [ToolboxData("<{0}:DatePicker runat=server></{0}:DatePicker>")]
 public class DatePicker : CompositeControl
 {
 
Note: Instead of asp tag prefix i have used SQ (Salman Qayyum :)Now we will add asp TextBox,Image and properties.
Properties
ImageUrl : URL for image. AutoPostBack: To set AutoPostBack true or false. Value: To access the value of date picker e.g datepicker. ImageCssClass: To style the image. TextBoxCssClass: To Style the textbox .
 
//To retrieve value i am using textbox
   private TextBox _TxtDate = new TextBox();
   // Image to select the calendar date
   private Image _ImgDate = new Image();
   // Image URL to expose the image URL Property
   private string _ImageUrl;
   // Exposing autopostback property
   private bool _AutoPostBack;
   // property get the value from datepicker.
   private string _Value;
   //CSS class to design the Image
   private string _ImageCssClass;
   //CSS class to design the TextBox
   private string _TextBoxCssClass;
 
   /**** properties***/
 
   [Bindable(true), Category("Appearance"), DefaultValue("")]
   public string ImageUrl
   {
     set
     {
       this._ImageUrl = value;
     }
   }
 
   [Bindable(true), Category("Appearance"), DefaultValue(""), Localizable(true)]
   public string Text
   {
     get
     {
       String s = (String)ViewState["Text"];
       return ((s == null) ? string.Empty : s);
     }
 
     set
     {
       ViewState["Text"] = value;
     }
   }
 
   [Bindable(true), Category("Appearance"), DefaultValue(""), Localizable(true)]
   public string Value
   {
     get
     {
 
       return _Value = _TxtDate.Text;
     }
 
     set
     {
       _Value = _TxtDate.Text = value;
     }
   }
   [Bindable(true), Category("Appearance"), DefaultValue(""), Localizable(true)]
   public bool AutoPostBack
   {
     get
     {
       return _AutoPostBack;
     }
 
     set
     {
       _AutoPostBack = value;
     }
   }
   [Bindable(true), Category("Appearance"), DefaultValue(""), Localizable(true)]
   public string ImageCssClass
   {
     get
     {
       return _ImageCssClass;
     }
 
     set
     {
       _ImageCssClass = value;
     }
   }
 
   [Bindable(true), Category("Appearance"), DefaultValue(""), Localizable(true)]
   public string TextBoxCssClass
   {
     get
     {
       return _TextBoxCssClass;
     }
 
     set
     {
       _TextBoxCssClass = value;
     }
   }
 
   [Bindable(true), Category("Custom"), DefaultValue(""), Localizable(true)]
   public string CommandName
   {
     get
     {
       string s = ViewState["CommandName"] as string;
       return s == null ? String.Empty : s;
     }
     set
     {
       ViewState["CommandName"] = value;
     }
   }
 
   [Bindable(true), Category("Custom"), DefaultValue(""), Localizable(true)]
   public string CommandArgument
   {
     get
     {
       string s = ViewState["CommandArgument"] as string;
       return s == null ? String.Empty : s;
     }
     set
     {
       ViewState["CommandArgument"] = value;
     }
   }
 
Above I have also added CommandName and CommandArgument property to make this date picker work inside data navigation controls.
Generating Bubble Event
 
Event bubbling enables events to be raised from a more convenient location in the controls hierarchy and allows event handlers to be attached to the original control as well as to the control that exposes the bubbled event. Event bubbling is used by the data-bound controls to expose command events raised by child controls (within item templates) as top-level events. While ASP.NET server controls in the .NET Framework use event bubbling for command events (events whose event data class derives from CommandEventArgs), any event defined on a server control can be bubbled.
 
protected static readonly object EventCommandObj = new object();
 
   public event CommandEventHandler Command
   {
     add
     {
       Events.AddHandler(EventCommandObj, value);
     }
     remove
     {
       Events.RemoveHandler(EventCommandObj, value);
     }
   }
   //this will raise the bubble event
   protected virtual void OnCommand(CommandEventArgs commandEventArgs)
   {
     CommandEventHandler eventHandler = (CommandEventHandler)Events[EventCommandObj];
     if (eventHandler != null)
     {
       eventHandler(this, commandEventArgs);
     }
     base.RaiseBubbleEvent(this, commandEventArgs);
   }
   //this will be initialized to  OnTextChanged event on the normal textbox
   private void OnTextChanged(object sender, EventArgs e)
   {
     if (this.AutoPostBack)
     {
       //pass the event arguments to the OnCommand event to bubble up
       CommandEventArgs args = new CommandEventArgs(this.CommandName, this.CommandArgument);
       OnCommand(args);
     }
   }
 
We will raise this bubble event with texbox.OnTextChanged using OnInit function as below.
 
Note: Always create dynamic controls inside OnInit function because viewstate reloads after OnInit and before the Load event. So if you want to keep the viewstate on postback then the best place to keep the code is inside OnInit
 
protected override void OnInit(EventArgs e)
   {
     //AddStyleSheet();
     //AddJavaScript();
     base.OnInit(e);
 
     // For TextBox
     // setting name for textbox. using t just to concat with this.ID for unqiueName
     _TxtDate.ID = this.ID + "t";
     // setting postback
     _TxtDate.AutoPostBack = this.AutoPostBack;
     // giving the textbox default value for date
     _TxtDate.Text = this.Value;
     //Initializing the TextChanged with our custom event to raise bubble event
     _TxtDate.TextChanged += new System.EventHandler(this.OnTextChanged);
     //Setting textbox to readonly to make sure user dont play with the textbox
     _TxtDate.Attributes.Add("readonly", "readonly");
     // adding stylesheet
     _TxtDate.Attributes.Add("class", this.TextBoxCssClass);
 
     // For Image
     // setting alternative name for image
     _ImgDate.AlternateText = "imageURL";
     if (!string.IsNullOrEmpty(_ImageUrl))
       _ImgDate.ImageUrl = _ImageUrl;
     
     //setting name for image
     _ImgDate.ID = this.ID + "i";
     //setting image class for textbox
     _ImgDate.Attributes.Add("class", this.ImageCssClass);
   }
 
Now we will add and render controls
 
/// <summary>
  /// adding child controls to composite control
  /// </summary>
  protected override void CreateChildControls()
  {
    this.Controls.Add(_TxtDate);
    this.Controls.Add(_ImgDate);
    base.CreateChildControls();
  }
 
  public override void RenderControl(HtmlTextWriter writer)
  {
    // render textbox and image
    _TxtDate.RenderControl(writer);
    _ImgDate.RenderControl(writer);
    RenderContents(writer);
  }
 
Replace or add your RenderContents function with
 
/// <summary>
  /// Adding the javascript to render the content
  /// </summary>
  /// <param name="output"></param>
  protected override void RenderContents(HtmlTextWriter output)
  {
    StringBuilder calnder = new StringBuilder();
    //adding javascript first
    calnder.AppendFormat(@"<script type='text/javascript'>
                 document.observe('dom:loaded', function() {{
                  Calendar.setup({{
                  dateField: '{0}',
                  triggerElement: '{1}',
                  dateFormat: '%d/%m/%Y'
                 }})
                }});
              ", _TxtDate.ClientID, _ImgDate.ClientID);
    calnder.Append("</script>");
    output.Write(calnder.ToString());
  }
 
Above code is JavaScript code to make the calendar control to work using prototype. For more help kindly visit http://calendarview.org/.
We are almost there now
Now to test this file chose solution file add new website and name it DatePickerTest. Click on view from top menu and chose Toolbox if it’s not already opened. on toolbox click right button of mouse and chose items then click browse and navigate to datepicker project under bin directory add DatePicker.dll and click OK. DatePicker has seen added to your design view.
 
Drag and drop and on your page and start using it :)
 
<SQ:DatePicker ID="DatePicker1" runat="server"  ImageUrl="Javascript/CalendarIcon.gif" />
 
Adding JavaScript
 
<head id="Head1" runat="server">
 
 <script src="Javascript/prototype.js" type="text/javascript"></script>
 <script src="Javascript/calendarview.js" type="text/javascript"></script>
 <link href="Javascript/calendarview.css" rel="stylesheet" type="text/css" />
 <title></title>
</head>
 
To retrieve value useResponse.Write(DatePicker1.Value);
Inside repeater
 
<asp:Repeater ID="Repeater1" runat="server"  DataSourceID="SqlDataSource1"
  onitemcommand="Repeater1_ItemCommand">
  <ItemTemplate>
  <SQ:DatePicker ID="DatePicker2" runat="server" CommandName="Clicked" AutoPostBack="true" ImageUrl="Javascript/CalendarIcon.gif"  />
   <%# Eval("ProductName")%><br />
  </ItemTemplate>
</asp:Repeater>
 
Using ItemCommand event
 
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
   DatePicker.DatePicker dtp = (DatePicker.DatePicker)e.Item.FindControl("DatePicker2");
   if (e.CommandName == "Clicked")
   {
     Response.Write(dtp.Value);
   }
 }
  aneesa replied to Rohini Kuchadi
25-Oct-11 04:26 AM

DatePicker Control in ASP.Net

 

Most often we will get a requirement to capture date input from the users. Normally, we can do this with a textbox and asking user to input the date in a particular format using a help text near by the textbox. We will also have validation function that validates the inputted date for correct format.

Something like the below figure,

function SetDate(dateValue,ctl)

{

thisForm = window.opener.document.forms[0].elements[ctl].value= dateValue;

self.close();

}

 

Now in clnDatePicker_DayRender Event, write the follow code to call the javascript function 'SetDate'.

 

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)

 {

string ctrl = Request.QueryString["ctl"];

HyperLink hpl = new HyperLink();

hpl.Text = ((LiteralControl)e.Cell.Controls[0]).Text;

hpl.NavigateUrl = "javascript:SetDate('" + e.Day.Date.ToShortDateString() + "','"+ctrl+"');";

e.Cell.Controls.Clear();

e.Cell.Controls.Add(hpl);

}

 

By default, all the day links rendered by the calendar server control will generate a postback to the server. What we do here is instead of postback, we will call our custom SetDate() JavaScript function.

To do this, we will clear the table cell that contains the day link and replace with a HyperLink control with our javascript function attached to that. Refer the above code.

Execute the page and see it in action.

 

Using Calendar Extender control in AJAX Control Toolkit

The next option to provide a datepicker feature in asp.net is using the Calendar extender control from Ajax control toolkit.

 

How to construct this?

To use this feature, you need to download Ajax control toolkit from http://www.asp.net/AJAX/ajaxcontroltoolkit/.

Read my article http://www.codedigest.com/Articles/ASPNETAJAX/124_Ajax_Control_Toolkit_%e2%80%93_Introduction.aspx to integrate and know more about this toolkit.

I assume you have toolkit already installed and integrated in your visual studio.

1.    Drag a textbox control.

2.    Drag a CalenderExtender control.

3.    Set the textbox ID in the TargetControlID property of CalenderExtender control.

<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">

      </cc1:ToolkitScriptManager>

      <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>

      <cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDate" runat="server">

      </cc1:CalendarExtender>

 

Execute the page. You can see the datepicker control in action similar to below figure.

DatePicker with AJAX Control Toolkit

The drawbacks of this approach are,

1.    This technique has a dependency on ASP.Net AJAX framework and hence it requires the framework to be installed on the production server.

2.    Your page will be heavy due to the ASP.NET Ajax client-side framework scripts.

 

Next, we will see how we can provide datepicker feature using jQuery.

 

Downloads

http://www.codedigest.com/Articles/ArticleFiles/ZIPS/247.zip 

Using jQuery DatePicker Plug-in

Using jQuery date picker http://jqueryui.com/download is one of the best options if you want to construct a datepicker control in your asp.net projects.

How to use this?

1.    Download the latest version of jQuery library from the http://jquery.com/.

2.    Refer the following faq’s to integrate and use jQuery library in Visual Studio 2008.

http://www.codedigest.com/FAQ/22-What-is-jQuery--How-to-use-it-in-ASP-Net-Pages-.aspx

http://www.codedigest.com/FAQ/23-How-to-enable-jQuery-intellisense-in-Visual-Studio-2008-.aspx

3.    Download the jQuery datepicker plug-in from http://jqueryui.com/download This plug-in offers multiple features. You can download the customized version of the plug-in by selecting the features you require on the download page. The option UI Core is required for any feature you download. You can select the themes you require from the theme dropdown on the download page. Hence, the download includes the files that are necessary for the themes as well.

4.    Unzip and copy the script (plug-in) into your solution and add a reference to the plug-in in your aspx page. Also, you need to copy the css folder into your solution for the themes.

5.    Drag a textbox control from the toolbox into your aspx page.

6.    To make the jQuery calendar to appear you need to call the datepicker() function. Refer the below code,

<head runat="server">

    <title></title>

    <link type="text/css" href="css/smoothness/jquery-ui-1.7.1.custom.css" rel="stylesheet" />

   <script src="_scripts/jquery-1.3.2.min.js" type="text/javascript"></script>

   <script src="_scripts/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>

    <SCRIPT type="text/javascript">

      $(function() {

     $("#txtDate").datepicker();    

      });  

     </SCRIPT>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>

    </div>   

    </form>

</body>

Execute the page and you can see the jQuery calendar appearing when we click on the textbox. Refer the below figure,

DatePciker using jQuery DatePicker plugin

Refer http://jqueryui.com/demos/datepicker/ to know more and customize the jQuery datepicker.

Some of the advantages of using this control are,

Ø     It’s purely client side and requires no execution in serverside.

Ø     Can do more customization.

Ø     Since, this also downloads a javascript library to the client side we can try using google’s http://www.codedigest.com/CodeDigest/79-Using-the-JQuery-Library-hosted-by-Google-CDN-(Content-Distribution-Network)-in-ASP-Net-Applications.aspx for improved caching, etc.

 

Date Picker in ASP.Net

 It will be good and user friendly, if we provide a button next to the textbox which will pop up a calendar for the user to select a date, a datepicker control. This prevents the need to make the user type in a particular format and also will give a better user experience. Well, this can be implemented in various ways. This article will help us to build this control ourselves and also some of the other options available. Moving forward, this article will help us to create DatePicker control in 3 ways,

Ø     Using ASP.Net Calendar control.

Ø     Using Calendar Extender control in AJAX Control Toolkit.

Ø     Using jQuery DatePicker Plug-in.

 

Using ASP.Net Calendar control

1) Drag a TextBox to the WebForm and name it as 'txtDate'.

2) You can either use button control or an IMG to open the calendar.

 

Now write a JavaScript function to open the popup that is containing the Calender control.

function PopupPicker(ctl)

{

var PopupWindow=null;

PopupWindow=window.open('DatePicker.aspx?ctl='+ctl,'','width=250,height=250');

PopupWindow.focus();

}

 

Pass the textbox control name as a query string (here ctl) to the popup, so that the pop up window can populate the textbox control in the parent window with the date selected by you. I have used image button to open the Calendar. Refer the below code,

 

<img src="_images/images.jpg" style="cursor:hand;" onclick="PopupPicker('txtDate')" />

 

Since, we are passing the textbox id as a querystring we can reuse this control in multiple places in our project. Means, just pass the textbox id where you want to populate the date in the onclick function call.

 

Building DatePicker.aspx

1) Drag a Calendar Control into the webform.

2) Get the TextBox Control Name that is coming as query string.

3) Fill the Parent form's textbox with the selected date by using the following JavaScript function.

  aneesa replied to Rohini Kuchadi
25-Oct-11 04:29 AM

Using ASP.Net Calendar control

1) Drag a TextBox to the WebForm and name it as 'txtDate'.

2) You can either use button control or an IMG to open the calendar.

 

Now write a JavaScript function to open the popup that is containing the Calender control.

function PopupPicker(ctl)

{

var PopupWindow=null;

PopupWindow=window.open('DatePicker.aspx?ctl='+ctl,'','width=250,height=250');

PopupWindow.focus();

}

 

Pass the textbox control name as a query string (here ctl) to the popup, so that the pop up window can populate the textbox control in the parent window with the date selected by you. I have used image button to open the Calendar. Refer the below code,

 

<img src="_images/images.jpg" style="cursor:hand;" onclick="PopupPicker('txtDate')" />

 

Since, we are passing the textbox id as a querystring we can reuse this control in multiple places in our project. Means, just pass the textbox id where you want to populate the date in the onclick function call.

 

Building DatePicker.aspx

1) Drag a Calendar Control into the webform.

2) Get the TextBox Control Name that is coming as query string.

3) Fill the Parent form's textbox with the selected date by using the following JavaScript function.

 

function SetDate(dateValue,ctl)

{

thisForm = window.opener.document.forms[0].elements[ctl].value= dateValue;

self.close();

}

 

Now in clnDatePicker_DayRender Event, write the follow code to call the javascript function 'SetDate'.

 

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)

 {

string ctrl = Request.QueryString["ctl"];

HyperLink hpl = new HyperLink();

hpl.Text = ((LiteralControl)e.Cell.Controls[0]).Text;

hpl.NavigateUrl = "javascript:SetDate('" + e.Day.Date.ToShortDateString() + "','"+ctrl+"');";

e.Cell.Controls.Clear();

e.Cell.Controls.Add(hpl);

}

 

By default, all the day links rendered by the calendar server control will generate a postback to the server. What we do here is instead of postback, we will call our custom SetDate() JavaScript function.

To do this, we will clear the table cell that contains the day link and replace with a HyperLink control with our javascript function attached to that. Refer the above code.

Execute the page and see it in action.

Using Calendar Extender control in AJAX Control Toolkit

The next option to provide a datepicker feature in asp.net is using the Calendar extender control from Ajax control toolkit.

 

How to construct this?

To use this feature, you need to download Ajax control toolkit from http://www.asp.net/AJAX/ajaxcontroltoolkit/.

Read my article http://www.codedigest.com/Articles/ASPNETAJAX/124_Ajax_Control_Toolkit_%e2%80%93_Introduction.aspx to integrate and know more about this toolkit.

I assume you have toolkit already installed and integrated in your visual studio.

1.    Drag a textbox control.

2.    Drag a CalenderExtender control.

3.    Set the textbox ID in the TargetControlID property of CalenderExtender control.

<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">

      </cc1:ToolkitScriptManager>

      <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>

      <cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="txtDate" runat="server">

      </cc1:CalendarExtender>

 

Execute the page. You can see the datepicker control in action similar to below figure.

DatePicker with AJAX Control Toolkit

The drawbacks of this approach are,

1.    This technique has a dependency on ASP.Net AJAX framework and hence it requires the framework to be installed on the production server.

2.    Your page will be heavy due to the ASP.NET Ajax client-side framework scripts.

Using jQuery DatePicker Plug-in

Using jQuery date picker http://jqueryui.com/download is one of the best options if you want to construct a datepicker control in your asp.net projects.

How to use this?

1.    Download the latest version of jQuery library from the http://jquery.com/.

2.    Refer the following faq’s to integrate and use jQuery library in Visual Studio 2008.

http://www.codedigest.com/FAQ/22-What-is-jQuery--How-to-use-it-in-ASP-Net-Pages-.aspx

http://www.codedigest.com/FAQ/23-How-to-enable-jQuery-intellisense-in-Visual-Studio-2008-.aspx

3.    Download the jQuery datepicker plug-in from http://jqueryui.com/download This plug-in offers multiple features. You can download the customized version of the plug-in by selecting the features you require on the download page. The option UI Core is required for any feature you download. You can select the themes you require from the theme dropdown on the download page. Hence, the download includes the files that are necessary for the themes as well.

4.    Unzip and copy the script (plug-in) into your solution and add a reference to the plug-in in your aspx page. Also, you need to copy the css folder into your solution for the themes.

5.    Drag a textbox control from the toolbox into your aspx page.

6.    To make the jQuery calendar to appear you need to call the datepicker() function. Refer the below code,

<head runat="server">

    <title></title>

    <link type="text/css" href="css/smoothness/jquery-ui-1.7.1.custom.css" rel="stylesheet" />

   <script src="_scripts/jquery-1.3.2.min.js" type="text/javascript"></script>

   <script src="_scripts/jquery-ui-1.7.1.custom.min.js" type="text/javascript"></script>

    <SCRIPT type="text/javascript">

      $(function() {

     $("#txtDate").datepicker();    

      });  

     </SCRIPT>

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>

    </div>   

    </form>

</body>

Execute the page and you can see the jQuery calendar appearing when we click on the textbox. Refer the below figure,

DatePciker using jQuery DatePicker plugin

Refer http://jqueryui.com/demos/datepicker/ to know more and customize the jQuery datepicker.

Some of the advantages of using this control are,

Ø     It’s purely client side and requires no execution in serverside.

Ø     Can do more customization.

Ø     Since, this also downloads a javascript library to the client side we can try using google’s http://www.codedigest.com/CodeDigest/79-Using-the-JQuery-Library-hosted-by-Google-CDN-(Content-Distribution-Network)-in-ASP-Net-Applications.aspx for improved caching, etc.

 

Downloads

http://www.codedigest.com/Articles/ArticleFiles/ZIPS/247.zip 

  James H replied to Rohini Kuchadi
25-Oct-11 04:33 AM
Hi you can add the date time picker like this 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DateTimePicker_UI.aspx.cs"
  Inherits="DateTimePicker_UI" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title></title>
  <link href="jquery-ui-1.8.14.custom/css/ui-lightness/jquery-ui-1.8.14.custom.css"
    rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.js">   
  </script>
  <script src="jquery-ui-1.8.14.custom/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript"></script>
  <script src="jquery-ui-1.8.14.custom/development-bundle/ui/jquery.ui.datepicker.js"
    type="text/javascript"></script>
  <script type="text/javascript">
    $(document).ready(function () {
      //$('#iText1').datepicker();
      $("#iText1").datepicker({ dateFormat: 'yy-dd-MM' });
      $('#iText2').datepicker();
      $('#btnGenerate').click(function () {
        OnSelect();
      });
    });
    function OnSelect() {
      var txtbx1 = $('#iText1').val();
      var txtbx2 = $('#iText2').val();
      if (txtbx1 == '') {
        alert('Please select From Date');
      }
      else if (txtbx2 == '') {
        alert('Please select To Date');
      }
      if (txtbx1 != '' && txtbx2 != '') {
        alert("Good you have selected both date's");
      }
    }
  </script>
</head>
<body>
  <form id="form1" runat="server">
  <div id="datetimepicker" class="ui-datepicker-multi-2">
    <table>
      <tr>
        <td>
          From:
        </td>
        <td>
          <input type="text" class="ui-datepicker-multi-2" id="iText1" />
        </td>
      </tr>
      <tr>
        <td>
          To:
        </td>
        <td>
          <input type="text" class="ui-datepicker-multi-2" id="iText2" />
        </td>
      </tr>
      <tr>
        <td colspan="2" >
          <input type="button" id="btnGenerate" value="Generate" style="margin-left:50px"/>
        </td>
      </tr>
    </table>
  </div>
  </form>
</body>
</html>
  Sree K replied to Rohini Kuchadi
25-Oct-11 04:35 AM
Hi

jQuery Calendar with time picker

While we thought the jQuery Calendar was the best calendar out there, we needed a way to select times. So the jQuery Calendar was extended with a basic time selector. It supports both AM/PM and 24 hour notation. In addition, a function was added to the calendar that parses a text string and outputs a Javascript Date object; a possible use case is the transformation of the selected date into a custom format before submitting it to the server. Keyboard shortcuts for changing the time are not supported yet and are also not a high priority for us, so anyone willing to add them is more than welcome to.

A single setting was added to the jQuery Calendar class: timeSeparators. It takes an array of strings as an argument with the following members:

  1. The date/time separator (separates the date part from the time part)
  2. The hour/minute separator
  3. (optional) The AM designator
  4. (optional) The PM designator

Examples of the time descriptor format are timeSeparators:[' ',':'] for the 24 hour format and timeSeparators:[' ',':','AM','PM'] for the AM/PM format.
http://razum.si/jQuery-calendar/TimeCalendar.html

  Suchit shah replied to Rohini Kuchadi
25-Oct-11 04:53 AM
For Date you can use the AjaxCalender Extender Control it is quite useful to use the date.. you can Implement it by below sample

<asp:TextBox ID="txtorderdate" runat="server" CssClass="textbox"></asp:TextBox>

<%--<asp:RequiredFieldValidator ID="rfvtxtorderdate" runat="server" ControlToValidate="txtorderdate"

ErrorMessage="**"></asp:RequiredFieldValidator>--%>

<ajax:CalendarExtender ID="CE1" runat="server" Enabled="True" Format="dd/MM/yyyy"

TargetControlID="txtorderdate">

</ajax:CalendarExtender>

After implementing this once you textbox focus come on that textbox ... Calender entender is popup.. and it will set the date in to the textbox

Create New Account
help
visual studio installation problem Actually, my OS is Windows Xp with service pack2.I added service pack3 to install visual studio2010.after that i tryed to installed, but am getting SETUP FAILED due to "Windows XP is not installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates Microsoft Visual F# 2.0 Runtime was not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio Macro Tools was not attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui attempted to be installed. [08 / 10 / 11, 14:26:00] VS70pgui: [2] DepCheck indicates .NET Framework 4 Multi-Targeting Pack was not attempted to be installed. [08 / 10 / 11, 14:26:01] VS70pgui: [2] DepCheck indicates Microsoft Visual Studio 2010 Professional - ENU was not attempted to be installed. [08 / 10 / 11, 14:26
Interview Questions for .NET Framework This article is specially for the users those are in development or want to be Microsoft.Jet.OLEDB.4.0;”+ _ “Data Source = C: \ Documents and Settings \ User \ My Documents \ Visual Studio Projects \ 1209 \ db1.mdb”+ _ “User ID = Admin;”+ _ “Password = ;”); Dim cmd As New OleDbCommand in Sql server as var_name int How do you separate business logic while creating an ASP.NET application? There are two level of asp.net debugging 1. Page level debugging For this we have to edit the page level debugging the corresponding date and time written Steps are:- Creating a CalenderControl 1) To begin, open Visual Studio .NET and begin a new C# Windows Control Library. 2) You may name it
Net hi friends Any one send frequently asked Important questions in C# .Net, ADO .Net, Asp .Net and Sql Server. . . . . . . . tx in Advance. . . . . . Hi, Find this. . (B)What is an IL? (B A) What is scavenging? (B) What are different types of caching using cache object of ASP.NET? (B) How can you cache different version of same page using ASP.NET cache object? (A) How will implement Page Fragment Caching? (B) Can you compare ASP.NET sessions with classic ASP? (B) Which are the various modes of storing ASP.NET session
Migration from ASP to ASP.net How to convert ASP site to ASP.NET site using C# http: / / www.asp.net / downloads / archived-v11 / migration-assistants / asp-to-aspnet hi, ASP.NET framework is very much different from unstrucured ASP and there is no correct way to