This is the code for my Textbox (DepartureDateTB):
<asp:TextBox ID="DepartureDateTB"
runat="server"
CssClass="DepartureDateTB"
ClientIDMode="Static"
ontextchanged="DepartureDateTB_TextChanged"
EnabledViewState="False"
AutoPostBack="True">
</asp:TextBox>
<asp:CompareValidator ID="CompareValidator1"
runat="server"
ControlToCompare="ArrivalDateTextBox"
ControlToValidate="DepartureDateTB"
ErrorMessage="*Departure to be greater"
ForeColor="Red"
Operator="GreaterThan">
</asp:CompareValidator>
JQuery for Date Picker:
$(function () {
$("[id$='DepartureDateTB']").datepicker({ minDate: 0, maxDate: "+30D" });
$("[id$='DepartureDateTB']").datepicker("option", "dateFormat", "dd/mm/yy");
});
</script>
On Page load, I am assigning a value to the textbox from database.
Then when the user changes it, there's a postback but the changed value is not retained.
Even when I tried assigning a Session variable to it and then equate it, all I get is an empty textbox.
Session["DepDateTB"] = (Request.Form[DepartureDateTB.UniqueID]).ToString();
DepartureDateTB.Text = Session["DepDateTB"].ToString();
And when I position a break point and run it, when I hover over the Textbox the value of it is the changed date but the textbox in the front end is again empty.
!IsPostBackin yourPage_Loadevent. Included one and inside it add Initial data.