我正在使用 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");
}
最佳答案
此片段可能对您有帮助:
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;
}
关于javascript - 按用户更改日期标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36194047/