Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在asp.net中使用MaskedEditExtender在文本框中显示当前日期和时间_C#_Asp.net_Date_Datetime_Asp.net Ajax - Fatal编程技术网

C# 在asp.net中使用MaskedEditExtender在文本框中显示当前日期和时间

C# 在asp.net中使用MaskedEditExtender在文本框中显示当前日期和时间,c#,asp.net,date,datetime,asp.net-ajax,C#,Asp.net,Date,Datetime,Asp.net Ajax,我尝试在txtDateTime中显示当前日期时间 如何使用asp.net中的Maked Edit Extender Ajax工具包在文本框中显示当前日期时间或自定义日期时间 <asp:TextBox runat="server" ID="txtDateTime" ValidationGroup="ModalPopup"></asp:TextBox> <asp:CalendarEx

我尝试在txtDateTime中显示当前日期时间 如何使用asp.net中的Maked Edit Extender Ajax工具包在文本框中显示当前日期时间或自定义日期时间

<asp:TextBox runat="server" ID="txtDateTime" ValidationGroup="ModalPopup"></asp:TextBox>
                                            <asp:CalendarExtender runat="server"
                                                TargetControlID="txtDateTime"
                                                PopupPosition="TopRight" 
                                                Format="dd/MM/yyyy HH:mm">
                                            </asp:CalendarExtender>
                                            <asp:MaskedEditExtender runat="server"
                                                ID="meeDateTime"
                                                TargetControlID="txtDateTime"
                                                Mask="99/99/9999 99:99"
                                                MaskType="DateTime"
                                                UserDateFormat= "DayMonthYear"
                                                UserTimeFormat="TwentyFourHour"
                                                CultureDateFormat="DMY"
                                                CultureDatePlaceholder="/"           CultureTimePlaceholder=":">
                                            </asp:MaskedEditExtender>

protected void Page_Load(object sender, EventArgs e)
        {
//txtDateTime.Text = DateTime.Now.ToString("dd/MM/yyyy H:mm);
//txtDateTime.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm);
txtDateTime.Text = DateTime.Now.ToString();
}

受保护的无效页面加载(对象发送方、事件参数e)
{
//txtDateTime.Text=DateTime.Now.ToString(“dd/MM/yyyyy H:MM”);
//txtDateTime.Text=DateTime.Now.ToString(“dd/MM/yyyy HH:MM”);
txtDateTime.Text=DateTime.Now.ToString();
}

代码隐藏

您不必在
txtDateTime.Text
中编写代码,因为您使用的是ajax控件

您已经设置了
TargetControlID=“txtDateTime”
,因此它将自动在该文本框中获取日期

如果要将其纳入屏蔽编辑扩展器,则:

 txtDateTime.Text =   String.Format("{0:t}", Now);

根据要设置日期的格式,可以编辑String.format。

以何种格式显示日期时间。。??