ASP.NET与jQuery DatePicker [英] ASP.NET with jQuery DatePicker
本文介绍了ASP.NET与jQuery DatePicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想这样做: http://jqueryui.com/datepicker/
但是,我不太确定如何:
However, I'm not exactly sure how:
- 我有一个主页 - 内容页面,当我尝试复制该代码并将其粘贴到内容页面时,它会说XXXX不能在内容区域。
- 当用户点击提交按钮,我如何将
文本框
中的日期传递给服务器端代码?
- I have a masterpage-content page, and when I tried to copy that code and paste them into the content page, it will say "XXXX cannot be in the content region".
- When the user hit the submit button, how am I going to pass the date in the
textbox
to the server side code?
以下是我的代码部分:
.aspx: p>
.aspx:
<asp:Content ID="Content4" ContentPlaceHolderID="MainContent1" runat="server">
<p>Date: <input type="text" id="datepicker"></p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
<asp:Label ID="lblOutput" runat="server" Text="Label"></asp:Label>
</asp:Content>
.cs:
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblOutput.Text = //The date from the datepicker
}
推荐答案
您需要使用 runat =server
在你的html中这样:
You need to use the runat="server"
like this in your html:
<input type="text" id="datepicker" runat="server">
然后在服务器端可以参考 datepicker
作为服务器对象,并访问 datepicker.Value
。
Then on your server side your can refer to datepicker
as a server object and access datepicker.Value
.
到@CJ评论。这是此链接中包含的源代码,其中添加了这个问题,那里是那里的 runat = server
去:
To @C.J comment. This is the source code included on this link added on the question, it is there where the runat=server
goes:
这是您的母版页:
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
这是您的内容页:
<p>Date: <input type="text" id="datepicker" class="datepicker"></p>
<script>
$(document).on('ready',function() {
$( ".datepicker" ).datepicker();
});
</script>
这篇关于ASP.NET与jQuery DatePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文