Reputation: 29
I have a problem, I want to compare the value from the datepicker ins aspx. with the value in a ms sql table column. I already created the input datepicker and the function in javascript, but I don't know how to use in c# code-behind the value that I chose! Can someone please help me?
$(function () {
$("#anfang").datepicker({
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'heute', currentStatus: '',
todayText: 'heute', todayStatus: '',
clearText: '-', clearStatus: '',
closeText: 'schließen', closeStatus: '',
monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni',
'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
monthNamesShort: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun',
'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
dayNames: ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'],
dayNamesShort: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
dayNamesMin: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
showMonthAfterYear: false,
showOn: 'both',
dateFormat: 'yy-mm-dd',
defaultDate: "+0w",
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#Label1").datepicker("option", "minDate", selectedDate);
}
});
$("#ende").datepicker({
prevText: '<zurück', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Vor>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'heute', currentStatus: '',
todayText: 'heute', todayStatus: '',
clearText: '-', clearStatus: '',
closeText: 'schließen', closeStatus: '',
monthNames: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni',
'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
monthNamesShort: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun',
'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
dayNames: ['Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag', 'Sonntag'],
dayNamesShort: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
dayNamesMin: ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'],
showMonthAfterYear: false,
beforeShow: customRange,
showOn: 'both',
dateFormat: 'yy-mm-dd',
defaultDate: "+0w",
changeMonth: true,
numberOfMonths: 1,
onClose: function (selectedDate) {
$("#Label2").datepicker("option", "maxDate", selectedDate);
}
});
})
and:
<asp:Label ID="von" runat="server" Text="Von: "></asp:Label>
<input type="text" id="anfang" />
<asp:Label ID="bis" runat="server" Text="Bis: "></asp:Label>
<input type="text" id="ende" />
Upvotes: 1
Views: 70
Reputation: 45997
replace
<input type="text" id="anfang" />
with
<asp:TextBox ID="anfang" runat="server" ClientIDMode="Static"></asp:TextBox>
to make your input elements anfang
and ende
serverside and access them codebehind with
string result = anfang.Text;
Upvotes: 1