admin管理员组文章数量:1287792
I would like to do something like this: /
However, I'm not exactly sure how:
- 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?
Here are parts of my code:
.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
}
I would like to do something like this: http://jqueryui./datepicker/
However, I'm not exactly sure how:
- 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?
Here are parts of my code:
.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
}
Share
Improve this question
edited May 21, 2014 at 14:41
DanM7
2,2463 gold badges29 silver badges47 bronze badges
asked May 21, 2014 at 14:13
C.J.C.J.
3,5279 gold badges38 silver badges53 bronze badges
3 Answers
Reset to default 4You need to use the runat="server"
like this in your html:
<input type="text" id="datepicker" runat="server">
Then on your server side your can refer to datepicker
as a server object and access datepicker.Value
.
To @C.J ment. This is the source code included on this link added on the question, it is there where the runat=server
goes:
This goes on your Master Page:
<script src="//code.jquery./jquery-1.10.2.js"></script>
<script src="//code.jquery./ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
This goes on your Content Page:
<p>Date: <input type="text" id="datepicker" class="datepicker"></p>
<script>
$(document).on('ready',function() {
$( ".datepicker" ).datepicker();
});
</script>
HTML5 use type="date"
<asp:TextBox ID="tbDate" runat="server" type="date"></asp:TextBox>
You need to initialize your datepicker and add runat="server"
to your input like this:
$(function() {
$("#datepicker").datepicker();
});
<input type="text" id="datepicker" runtat="server">
本文标签: cASPNET with jQuery DatePickerStack Overflow
版权声明:本文标题:c# - ASP.NET with jQuery DatePicker - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741318526a2372065.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论