所以当我点击选择按钮时,日历会出现,我可以选择一个日期,然后在我选择一个日期后消失。问题是每次单击按钮时都会重新加载整个页面,有什么办法可以防止吗?
我是 ASP.NET 的新手?这是事件的设计代码和实际代码:
<tr>
<td>
Expired Date
</td>
<td>
<asp:TextBox ID="txtExpDate" runat="server"></asp:TextBox>
<asp:Button ID="btnSelectDate" runat="server" OnClick="btnSelectDate_Click" Text="Select" />
<asp:Button ID="btnClearDate" runat="server" OnClick="btnClearDate_Click" Text="Clear" />
</td><td></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Calendar ID="calExpiredDate" runat="server" BackColor="White" BorderColor="#3366CC" BorderWidth="1px" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="#003399" Height="200px" Visible="False" Width="220px" OnSelectionChanged="calExpiredDate_SelectionChanged">
<DayHeaderStyle BackColor="#99CCCC" ForeColor="#336666" Height="1px" />
<NextPrevStyle Font-Size="8pt" ForeColor="#CCCCFF" />
<OtherMonthDayStyle ForeColor="#999999" />
<SelectedDayStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
<SelectorStyle BackColor="#99CCCC" ForeColor="#336666" />
<TitleStyle BackColor="#003399" BorderColor="#3366CC" BorderWidth="1px" Font-Bold="True" Font-Size="10pt" ForeColor="#CCCCFF" Height="25px" />
<TodayDayStyle BackColor="#99CCCC" ForeColor="White" />
<WeekendDayStyle BackColor="#CCCCFF" />
</asp:Calendar>
<br />
</td><td>
</td>
</tr>
protected void btnSelectDate_Click(object sender, EventArgs e)
{
if (calExpiredDate.Visible == false) calExpiredDate.Visible = true;
else calExpiredDate.Visible = false;
}
protected void btnClearDate_Click(object sender, EventArgs e)
{
txtExpDate.Text = null;
}
protected void calExpiredDate_SelectionChanged(object sender, EventArgs e)
{
txtExpDate.Text = calExpiredDate.SelectedDate.ToShortDateString();
calExpiredDate.Visible = false;
}