Link to home
Start Free TrialLog in
Avatar of Member_2_1242703
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

<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>

Open in new window


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.
Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

Try add 'onchange' to the textbox

<asp:TextBox ID="tbFiscalWeek" runat="server" CssClass="form-control" name="FiscalWeekff" AutoPostBack="True" onchange="return dateSelectedFn();"></asp:TextBox>
Avatar of Prakash Samariya
Change like below in .aspx page (add OnTextChanged="tbFiscalWeek_TextChanged" 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>

Open in new window

Make event handler in aspx.cs (code) file
 protected void tbFiscalWeek_TextChanged(object sender, EventArgs e)
        {
            //write your code
        }

Open in new window

Avatar of Member_2_1242703
Member_2_1242703

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
Avatar of Prakash Samariya
Prakash Samariya
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial