如何使用c#从asp.net中的日历选择当前日期后,将当前日期提取到文本框字段中 [英] how to fetch the current date into the textbox field after selecting the current date from calender in asp.net using c#

查看:313
本文介绍了如何使用c#从asp.net中的日历选择当前日期后,将当前日期提取到文本框字段中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#

推荐答案

<asp:calendar id="Calendar1" runat="server" xmlns:asp="#unknown">
      onselectionchanged="Calendar1_SelectionChanged"></asp:calendar>










protected void Calendar1_SelectionChanged(object sender, EventArgs e)
       {
           var dt = Calendar1.SelectedDate.ToShortDateString();
           TextBox1.Text = Convert.ToString(dt);

       }


在日历控制的Day_Render事件中编写代码。工作正常。

Write the code in Day_Render event of calender control.Working fine.
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        TextBox1.Text = Calendar1.SelectedDate.ToString();
    }


这篇关于如何使用c#从asp.net中的日历选择当前日期后,将当前日期提取到文本框字段中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆