how to use datetimepicker control in asp.net
  • datetimepicker in asp.net using c# here is source code.
    image

    Default.aspx

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!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>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
         Your selected date is<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Panel Runat="server" ID="Panel1" >
                    <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="PickDate" ForeColor="Green" ></asp:Calendar>
                    </asp:Panel>
          
        </div>
        </form>
    </body>
    </html>

    Default.aspx.cs



    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    private void ToggleCalendar()
    {
    Panel1.CssClass = ("calendarHide" == Panel1.CssClass) ? ("calendarShow") : ("calendarHide");
    //btnDate.Text = ("Hide Calendar" == btnDate.Text) ? ("Show Calendar") : ("Hide Calendar");
    }
    public void PickDate(object sender, EventArgs e)
    {
    TextBox1.Text = Calendar1.SelectedDate.Day.ToString("00") + "/" + Calendar1.SelectedDate.Month.ToString("00") + "/" + Calendar1.SelectedDate.Year.ToString("0000");
    ToggleCalendar();
    }
    }


    dtpAsp.JPG
    283 x 252 - 17K

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

Optimum Creative