<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css" type="text/css" media="all" /> <link rel="stylesheet" href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" media="all" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { $("#TextBox1").datepicker({ changeMonth: true, changeYear: true }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <%--<input runat="server" type="text" id="txtFoo" />--%> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /></div> <asp:Label ID="Label1" runat="server" ></asp:Label> </form> </body> </html>
namespace datepicker { public partial class WebForm1 : System.Web.UI.Page { SqlConnection cn = new SqlConnection("Data Source=AB19726;Initial Catalog=datepicker;Integrated Security=True"); SqlCommand cmd = new SqlCommand(); protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { cn.Open(); //DateTime dat= DateTime.Parse(TextBox1.Text.ToString()); cmd = new SqlCommand("insert into date (ID,date)values(3," +Convert.ToDateTime(TextBox1.Text.ToString()) + ")", cn); cmd.ExecuteNonQuery(); Label1.Text = "insert successed !!"; cn.Close(); } } }
DateTime dat = DateTime.ParseExact(TextBox1.Text.ToString().Trim(), "M/d/yyyy h:mm:ss tt", CultureInfo.InvariantCulture);
DateTime dat = Convert.ToDateTime(TextBox1.Text);
DateTime dt; DateTime.TryParseExact(TextBox1.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt); TextBox1.Text = dt.ToString("yyyy/MM/dd");
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)