Member_2_1242703
asked on
Firing an ASP.NET event on selection of a JQuery datepicker
I have the following TextBox/DatePicker in an ASP.NET web application
Is there any way for me to fire an event in my code behind when a date is selected? I'm struggling to even get a client function to fire.
<div class="input-group input-append date" data-date-format="mm/dd/yyyy" id="dp5"><asp:TextBox ID="tbFiscalWeek" runat="server" CssClass="form-control" name="FiscalWeekff" AutoPostBack="True"></asp:TextBox><span class="input-group-addon add-on dp3"><i class="icon-calendar"></i></span></div>
Is there any way for me to fire an event in my code behind when a date is selected? I'm struggling to even get a client function to fire.
Change like below in .aspx page (add OnTextChanged="tbFiscalWee k_TextChan ged" in your textbox
<div class="input-group input-append date" data-date-format="mm/dd/yyyy" id="dp5">
<asp:TextBox ID="tbFiscalWeek" runat="server" CssClass="form-control" name="FiscalWeekff" AutoPostBack="True"
OnTextChanged="tbFiscalWeek_TextChanged"></asp:TextBox>
<span class="input-group-addon add-on dp3"><i class="icon-calendar"></i></span></div>
Make event handler in aspx.cs (code) file
protected void tbFiscalWeek_TextChanged(object sender, EventArgs e)
{
//write your code
}
ASKER
That works if I actually type something in the text box but not upon selection from a calendar. In order to make this work I would have to select the date, refocus on the text box, then focus off/hit enter. I'm trying to get the code to run when the selection is made from the datepicker.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<asp:TextBox ID="tbFiscalWeek" runat="server" CssClass="form-control" name="FiscalWeekff" AutoPostBack="True" onchange="return dateSelectedFn();"></asp:TextBox>