简体   繁体   English

asp.net 4.0文本框不允许在文本框中输入javascript日期

[英]asp.net 4.0 text box doesn't allow to input javascript date in textbox

I am trying to set a date of today to indicate user to input date in the textbox. 我正在尝试设置今天的日期以指示用户在文本框中输入日期。 To indicate this I have wrote this small javascript/jquery , and this is working in other test project but it is not working in my actual project. 为了说明这一点,我写了这个小javascript/jquery ,它在其他测试项目中有效,但在我的实际项目中不起作用。 I am wondering what I have done wrong. 我想知道我做错了什么。 Below is my script code: 下面是我的脚本代码:

$(document).ready(function () {
            var dObj = new Date();
            var foo = dObj.toLocaleDateString();
            $("#dte").val(foo);

        });

I am also confused about the position to attach a jquery link, whether it should be attach in .Master page or on content page before the corresponding close tag. 我也对附加一个jquery链接的位置感到困惑,无论该链接应附加在.Master页还是对应的close标签之前的content page Because when I attach this on master page it is giving me error like not able to find form1 and on latter one place it is not able to display the output in text box. 因为当我将其附加在母版页上时,它给我类似not able to find form1错误not able to find form1而在后一个地方,它无法在文本框中显示输出。

I have heard about placeholder and modernizer but it doesn't fulfil requirement of displaying date on page load. 我听说过placeholder和现代化器,但是它不满足在页面加载时显示日期的要求。 However, when ever I am giving value(date of today) to textbox inside Page_load method, i am not able to fetch the date that the user has selected. 但是,当我在Page_load方法中为文本框提供值(今天的日期)时,我无法获取用户选择的日期。 That is why I moved to this javascript solution. 这就是为什么我转向此javascript解决方案的原因。 I am using AJAX date calendar extender to display calendar. 我正在使用AJAX date calendar extender来显示日历。 Is it due to any ajax effect or something else. 是由于任何ajax效果还是其他原因。

please guide me regarding this. 请为此指导我。

Thanks!! 谢谢!!

Are you using server control TextBox? 您正在使用服务器控件TextBox吗? if so did you tried ClientID for JQuery selector 如果是这样,您是否尝试为JQuery选择器使用ClientID

$("#<%=dte.ClientID%>").val(foo);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM