Copy codeThe Code is as follows: <asp: TextBox ID = "txtDate" CssClass = "Wdate" Style = "width: 91px;" runat = "server"
Onfocus = "WdatePicker ({maxDate: '% y-% M-% d', isShowClear: false, readOnly: true })"
Onpropertychange = "showValue (this. value)"> </asp: TextBox>
Day
<Asp: HiddenField ID = "hiddenDate" runat = "server"
OnValueChanged = "hiddenDate_ValueChanged"
EnableViewState = "false"/>
<Div style = "display: none;">
<Asp: ImageButton ID = "btnHid" runat = "server"
ImageUrl = "~ /Resource/images/Btn_Find.gif"
CausesValidation = "false" align = "absmiddle"
OnClick = "btnHid_Click"/>
</Div>
To achieve this goal, you must use background code and javascript code. Javascript code
As follows:
Copy codeThe Code is as follows: <script type = "text/javascript">
// Record the date that the user entered last time.
Var today = new Date ();
Var todayMonth;
Var todayDate;
// Format the current "month" and "day.
If (today. getMonth () + 1) <10 ){
TodayMonth = "0" + (today. getMonth () + 1 );
}
If (today. getDate () <10 ){
TodayDate = "0" + today. getDate ();
}
// Obtain the current date.
Var oldValue = http://www.jb51.net/Health/archive/2012/02/10/today.getFullYear () + "-" + todayMonth + "-" + todayDate;
Function showValue (obj ){
// When the query date is not blank, the query button is triggered.
If (obj! = "" & Obj! = OldValue ){
OldValue = http://www.jb51.net/Health/archive/2012/02/10/obj;
$ ('# TxtName'). get (0). select ();
$ ("# HiddenDate"). val (obj );
$ ('# BtnHid'). trigger ("click ");
Return false;
}
}
</Script>
Javascript code mainly determines whether the selected date is not blank and is a new date. Will trigger
The OnValueChanged of the hidden control can also trigger a button event. Date control event
It is the javascript code used for onpropertychange = "showValue (this. value.
The following is the background code:
Copy codeThe Code is as follows: // query based on the selected time.
Protected void hiddenDate_ValueChanged (object sender, EventArgs e)
{
// Background code
}
// Query based on the selected time.
Protected void btnHid_Click (object sender, ImageClickEventArgs e)
{
// Background code
}
Both can be used.
This blog post only shows how to use the front-end non-Server Control text box (although this blog post uses Server Control
Is the same as HTML controls .), Text changes trigger background events to execute background code.