Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:27:37+00:00 2026-05-29T06:27:37+00:00

I have a asp:textbox with a OnTextChanged event that I want to fire when

  • 0

I have a asp:textbox with a OnTextChanged event that I want to fire when ever a new date is selected from the jQuery datepicker that is bound to it but when selecting a date, the OnTextChanged never fires. It fires if I change the text ‘by hand’ but I want to force the user to select the date from the datepicker. I need to run server side code each time the date is changed. I have tried using the onSelect method on the datepicker but was unable to get it to call the method.

Here is my client side code:

 function pageLoad() {
    $(".datepicker").datepicker({
        constrainInput: true,
        dateFormat: 'dd D M yy'
    });
}

<asp:UpdatePanel runat="server" ChildrenAsTriggers="True">
<ContentTemplate>
    <asp:TextBox ID="txtPickupDate" runat="server" OnTextChanged="txtPickupDate_TextChanged" CssClass="datepicker"
       AutoPostBack="true" >
    </asp:TextBox>
    <asp:DropDownList ID="ddlPickupTime" runat="server" />
</ContentTemplate>

Greatly appreciate any help

Update: Was asked to include the TextChanged function. Didn’t post it initially as it isn’t firing the method and figured it didn’t affect the solution but regardless, here it is:

protected void txtPickupDate_TextChanged(object sender, EventArgs e)
    {
        DateTime pickupDate = DateTime.Parse(txtPickupDate.Text);
        //do things with the date
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:27:38+00:00Added an answer on May 29, 2026 at 6:27 am

    I tested your code and the TextChanged server side method is being fired when the date is being selected on the datepicker.

    One slight change I made was refactoring the jquery to reside within $(document).ready() function

    <script type="text/javascript">
    $(document).ready(function() {
        $(".datepicker").datepicker({
            constrainInput: true,
            dateFormat: 'dd D M yy'
        });
    });
    </script>
    

    See the entire code below.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DatePickerTest.aspx.cs" Inherits="TestApp.DatePickerTest" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title></title>
    
    <script type='text/javascript' src='http://code.jquery.com/jquery-1.4.2.js'></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.js"></script>
    
    <link rel="stylesheet" type="text/css" href="/css/normalize.css"/>
    <link rel="stylesheet" type="text/css" href="/css/result-light.css"/>
    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/smoothness/jquery-ui.css"/>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="txtPickupDate" runat="server" OnTextChanged="txtPickupDate_TextChanged" CssClass="datepicker" AutoPostBack="true"></asp:TextBox>
    </div>
    </form>
    
    <script type="text/javascript">
    $(document).ready(function() {
        $(".datepicker").datepicker({
            constrainInput: true,
            dateFormat: 'dd D M yy'
        });
    });
    </script>
    
    </body>
    </html>
    

    And server side

    protected void txtPickupDate_TextChanged(object sender, EventArgs e)
    {
            DateTime pickupDate = DateTime.Parse(txtPickupDate.Text); 
    }
    

    EDIT as per comment below:

    To allow the TextChanged event to continue to fire after post back you can use

    .live() if not using the latest version of jquery as it is now deprecated

    $(function() {
        $('.datepicker').live('click', function() {
            $(this).datepicker({
                constrainInput: true, dateFormat: 'dd D M yy'
            }).focus();
        });
    });
    

    or .on() with the latest version of JQuery 1.7 and upwards

    $('body').on('click', '.datepicker', function() {
        $(this).datepicker({
            constrainInput: true, dateFormat: 'dd D M yy'
        }).focus();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp.net TextBox with ontextchanged event this is search text box in my
I have an asp:TextBox and I want to validate that the number of characters
I have a asp.net web content from that have a asp.net textbox and I
I have an asp:TextBox associated to a jquery DatePicker. This input has a onTextChangedEvent
I have an asp textbox that I have hooked up to a jQuery calendar
I have an asp.net TextBox in which I want to check if the text
I have an ASP.NET control. I want to align the textbox to the right
I have a textbox and a dropdownlist the textbox has <asp:TextBox ID=TxtInizioPeriodo runat=server ontextchanged=InizioPeriodo_TextChanged
Within an asp.net webform I have some jquery that controls the positioning of elements
I have three TextBox controls on the page <asp:TextBox ID=TextBox1 runat=server AutoPostBack=True OnTextChanged=TextBox_TextChanged TabIndex=1>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.