For the JS files to be used, visit http://d.download.csdn.net/down/2387457/taomanto download them for free;
The following describes how to use it:
Step 1:
Download the JS file from the address provided by me and decompress it to a directory of the project.
Step 2:
Add the wdatepicker. js file in the JS file to the ASPX page that requires the time control.
For example, <SCRIPT src = "../JS/my97datepicker/wdatepicker. js" type = "text/JavaScript"> </SCRIPT>
Add two text boxes. The time control is transformed by textbox. The Code is as follows:
<Asp: Panel id = "Panel1" style = "width: 100%" runat = "server">
Start time <input id = "tbstarttime" type = "text" runat = "server" style = "width: 102px"/>
End Time <input id = "tbendtime" type = "text" runat = "server" style = "width: 102px"/>
<Asp: button id = "btnquery" runat = "server" text = "query" onclick = "btnquery_click"/>
</ASP: Panel>
Step 3:
Add the following code to the background Aspx. CS file:
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
Adddatecontrol ();
Tbstarttime. value = datetime. Now. tostring ("yyyy-mm-dd ");
Tbendtime. value = datetime. Now. tostring ("yyyy-mm-dd ");
}
}
/// <Summary>
/// Set the date input box
/// </Summary>
Private void adddatecontrol ()
{
Tbstarttime. Attributes. Add ("class", "wdate ");
Tbstarttime. Attributes. Add ("onfocus", "New wdatepicker (this, '% Y-% m-% d', false )");
Tbendtime. Attributes. Add ("class", "wdate ");
Tbendtime. Attributes. Add ("onfocus", "New wdatepicker (this, '% Y-% m-% d', false )");
}
The above is the change to the text box style, this is the text box you see will be a datetimepicker, the effect is good, click the link below to view the effect: http://hi.csdn.net/space-95339-do-album-picid-551501.html
Next, you may be most concerned about how to obtain the time value. In fact, it is also very simple, as long as the value is as follows:
Datetime dtstart = datetime. parseexact (tbstarttime. value, "yyyy-mm-dd", system. Globalization. cultureinfo. currentculture );