Saturday, 3 August 2013

Adding Date Picker to a Textbox control and saving the corresponding Date in the database [ASP.NET(c#)]

In this example I am going to show you how to add 'Date Picker' to a 'Textbox' control in

First add a Textbox control at the aspx page:

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

Now inside head add this:

 <script src="" type="text/javascript"></script>
<script src="" type="text/javascript"></script>
    <link href="" rel="Stylesheet" type="text/css" />
   <script type="text/javascript">
        $(function () {
                showOn: 'button',
                buttonImageOnly: true,
                buttonImage: 'calendaricon.jpg'

At the code behind section(cs page) add this code at your event:

  SqlConnection conn = new SqlConnection("Your Connection String");
        SqlCommand cmd = new SqlCommand("insert into tablename values('"+Convert.ToDateTime(TextBox1.Text) + "' )", conn);

Download the JQUERY files

If you have any doubts regarding this code feel free to comment below.........


Post a Comment