日期/月份/年份必须自动显示在文本框中 [英] DATE / MONTH / YEAR Must be Displayed in Textbox Automatically
问题描述
亲爱的所有人,
我正在使用ASP.Net,C#和数据库作为sqlServer2005.
我有一个WEBFORM(Adduser.aspx),其中使用了以下字段.
名-TextBox
姓氏-TextBox
部门-文本框
用户名-文本框
密码-文字框
发布日期-文本框(在此文本框中,当用户单击此文本框时,必须自动显示日期/月/年)例如:18/04/2012
到期日期-文本框(在此文本框中,当用户单击此文本框时,必须自动显示日期/月/年). 2013年4月18日
最后将它们存储在数据库中.
但问题出在这里与IssueDate和ExpiryDate有关...当鼠标指针单击文本框时我自动需要它....请帮助.
谢谢,
Dear All,
Am using ASP.Net , C# and Database as sqlServer 2005.
I have a WEBFORM(Adduser.aspx) in which i have used these below fields.
First Name - TextBox
Last Name - TextBox
Department - TextBox
UserName - TextBox
Password - TextBox
Issue Date - TextBox (In this TextBox Date/Month/Year Must be Displayed Automatically When user clicks in this Textbox) Eg: 18/04/2012
Expiry Date - TextBox (In this TextBox Date/Month/Year Must be Displayed Automatically When user clicks in this Textbox) Eg ; 18/04/2013
and finally these will be stored in Database.
BUT THE PROBLEM AM GETTING HERE IS ABOUT IssueDate and ExpiryDate...I need it Automatically when the Mouse pointer Clicks the textbox ....Please help.
Thanks,
推荐答案
<asp:CalendarExtender ID="txtDate_CalendarExtender" runat="server"
Format="MM/dd/yyyy" PopupButtonID="imgCalendarFrom"
TargetControlID="txtDate">
</asp:CalendarExtender>
You can Add A calender button and Pic Date from there
<asp:ImageButton ID="imgCalendarFrom" runat="server" Height="17px"
ImageUrl="~/Images/calender.gif" onclick="imgCalendarFrom_Click" TabIndex="7"
Width="21px" />
您可以使用Ajax工具来做到这一点:
请参阅在鼠标悬停/单击时显示日历
请帮忙投票.
问候
Hi,
You may use the Ajax Tools to do that:
Please see Display a Calendar on mouse-over/click
Please do not forget to vote if could help.
Regards,
您可以使用"OnFocus"客户端事件来执行此操作.
为您的文本框添加onfocus事件
Hi,
You can use "OnFocus" client side event to do this.
Add onfocus event for your textbox
<asp:textbox ---- onfocus="return TextBoxFocus(this)" </asp:TextBox>
//javascript function
//This function can be called on any textbox
function TextBoxFocus(sender)
{
var date = new Date();
sender.value=date.getDate() + date.getMonth() + date.FullYear();
return true;
}
希望这会有所帮助.
hope this helps..
这篇关于日期/月份/年份必须自动显示在文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!