问题
I can't manage to set a date and to get a date of Datepicker in code behind(C#) does anyone have informations to give me about this ? thanks in advance!
<input id="datepicker" value="01/01/2011" type="text"/>
$(document).ready(function () {
$("#datepicker").datepicker();
});
回答1:
<input id="datepicker0" type="text" name="datepickernm"/>
You can get the value from below code in the codebehind:
String text = Page.Request.Form["datepickernm"]
回答2:
Use an ASP textbox control:
<asp:textbox runat="server" id="txtDate"/>
<script type="text/javascript">
$('#<%= txtDate.ClientID %>').datepicker();
</script>
This way you could get and set the value from code behind.
回答3:
The Calendar control in asp.net will provide you with the functionality you need. Drag the control from the Toolbox in Visual Studio
then access the Calendar control from codebehind using the ID
回答4:
The above method does not allow me to set the value from the code behind. I am only able to get the date from the code behind.
When i remove the javascript form the html header, it seems to works.. i think that the javascript is overriding the value in the textbox.
来源:https://stackoverflow.com/questions/9032068/how-to-set-a-date-get-a-date-for-datepicker-in-codebehind