我使用C#.net编程预订系统
我想让用户通过图片上显示的箭头更改日期(请点击链接)
日期图片
我已经在屏幕上显示当前日期,但我不知道如何让用户使用箭头更改日期 这些是html代码:
<asp:Label ID="lblServerDateTime" runat="server" CssClass="auto-style13" style="font-size:30px;" />
这些是 C#代码
protected void page_load(object sender, EventArgs e)
{
lblServerDateTime.Text = DateTime.Now.ToString("M");
}
答案 0 :(得分:2)
这个片段可以帮到你:
<强> .aspx的强>
<asp:Button Text="Down" ID="btnDown" runat="server" OnClick="btnDown_Click" />
<asp:Label ID="lblServerDateTime" runat="server" CssClass="auto-style13" Style="font-size: 30px;" />
<asp:Button Text="UP" ID="btnUp" runat="server" OnClick="btnUp_Click" />
代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lblServerDateTime.Text = DateTime.Now.ToString("dd MMMM");
calCurrentDay.SelectedDate = DateTime.Now;
// Sets current date on initially.
}
}
protected void btnUp_Click(object sender, EventArgs e)
{
//Up button click will increase the date by one day
DateTime.TryParse(lblServerDateTime.Text, out d);
d = d.AddDays(1);
lblServerDateTime.Text = d.ToString("dd MMMM");
calCurrentDay.SelectedDate = d;
}
protected void btnDown_Click(object sender, EventArgs e)
{
//Up button click will decrease the date by one day
DateTime d;
DateTime.TryParse(lblServerDateTime.Text, out d);
d = d.AddDays(-1);
lblServerDateTime.Text = d.ToString("dd MMMM");
calCurrentDay.SelectedDate = d;
}