Calendar control failing to trigger the OnTextChanged event in the textbox

I have integrated a calendar control from the internet for phone use, where users can scroll up and down to select a date and time before clicking 'Confirm' or 'Cancel'. However, I am not familiar with JavaScript. The relevant JavaScript code in my view is as follows:

...
<li id="dateconfirm">Confirm</li>'
...

        function bindButton(){
        resetIndex();
        $("#dateconfirm").unbind('click').click(function () {   
            var datestr = $("#yearwrapper ul li:eq("+indexY+")").html().substr(0,$("#yearwrapper ul li:eq("+indexY+")").html().length-1)+"-"+
                      $("#monthwrapper ul li:eq("+indexM+")").html().substr(0,$("#monthwrapper ul li:eq("+indexM+")").html().length-1)+"-"+
          $("#daywrapper ul li:eq("+Math.round(indexD)+")").html().substr(0,$("#daywrapper ul li:eq("+Math.round(indexD)+")").html().length-1);
           if(datetime){
                 if(Math.round(indexS)===1){//afternoon
                    $("#Hourwrapper ul li:eq("+indexH+")").html(parseInt($("#Hourwrapper ul li:eq("+indexH+")").html().substr(0,$("#Hourwrapper ul li:eq("+indexH+")").html().length-1))+12)
                 }else{
                    $("#Hourwrapper ul li:eq("+indexH+")").html(parseInt($("#Hourwrapper ul li:eq("+indexH+")").html().substr(0,$("#Hourwrapper ul li:eq("+indexH+")").html().length-1)))
                 }
                 datestr+=" "+$("#Hourwrapper ul li:eq("+indexH+")").html().substr(0,$("#Minutewrapper ul li:eq("+indexH+")").html().length-1)+":"+
                         $("#Minutewrapper ul li:eq("+indexI+")").html().substr(0,$("#Minutewrapper ul li:eq("+indexI+")").html().length-1);
                     indexS=0;
            }

            if(Ycallback===undefined){
                 if(docType){that.val(datestr);}else{that.html(datestr);}
            }else{
                                Ycallback(datestr);
            }
            $("#datePage").hide(); 
            $("#dateshadow").hide();
        });
        $("#datecancle").click(function () {
            $("#datePage").hide(); 
    $("#dateshadow").hide();
            Ncallback(false);
        });
    }

When the textbox gains focus, it triggers a pop-up calendar. Originally, its HTML was as follows:

$(function(){
$('#Time').date({theme:"datetime"});
});

<div>Date Set:<input id="Time"/></div>

To convert it from HTML to ASPX, I made some modifications:

$(function () {
$("#<%= txtDate.ClientID %>").date({ theme: "datetime" });
});   

<asp:TextBox ID="txtDate" runat="server" BorderWidth="0" OnTextChanged="txtDate_TextChanged" AutoPostBack="true" Font-Size="20" placeholder="Select Date"/>

Although the text on the textbox changes accordingly when I select a date/time and click 'Confirm', the OnTextChanged event does not trigger. Can someone help me understand why this is happening? Thanks.

Answer №1

When it comes to the textbox control, remember that "The event will only be triggered if the user changes the text themselves; it won't be triggered if the text is changed through code."

https://example.com/textbox-control-events

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Choosing an embedded iframe using selenium in javascript with node-js

When working with the selenium webdriver module in node-js, I encountered an issue trying to select a nested iframe within another iframe. Here's an example scenario: <iframe id="firstframe"> <div id="firstdiv"></div> <ifr ...

What could be causing my object to not be added properly to a select element using JavaScript programmatically?

When it comes to customizing your pizza, the options are endless. From selecting the type of crust to choosing your favorite toppings, every detail matters. One common issue that arises is when changing the crust type affects the available sizes ...

What is the best way to pass an SQL variable from an HTML table to a JS popup and then to a PHP variable without using jQuery?

My goal is to develop software for a job board where jobs can be added and maintenance workers can mark them as completed. I am currently facing an issue with passing the request_ID from my table to the SQL query at the bottom in deleteData(). Despite tryi ...

Setting default values for Select2 input with tagging in ASP.NET MVC is a simple process that can greatly enhance the user experience

I am currently utilizing a Select2 input box as a tag controller in my view: CSHTML <input id="tagSelector" type="hidden" style="width: 300px"/> JS $('#tagSelector').select2({ placeholder: 'Select a tag...', ...

Utilizing the power of AngularJS with ng-class for dynamic styling and

I recently started learning AngularJs and I have a question about how angular handles the ng-class attribute. While working with external libraries for visualization, charts, etc., I often need to trigger the resize event: window.dispatchEvent(new Event( ...

JSON.stringify alters the format of a date object

I have a website where users can log in with a specific timezone, regardless of the client-side timezone. When a user selects a date on the website, it is sent to the server side using JSON.stringify along with other properties. However, when the date is r ...

Choosing a single item from multiple elements in React using React and typescript

In this particular project, React, TypeScript, and ant design have been utilized. Within a specific section of the project, only one box out of three options should be selected. Despite implementing useState and toggle functionalities, all boxes end up bei ...

Transforming card dimensions with Bootstrap

I am currently working on my web portfolio and I am looking to create a card format that includes an image thumbnail with text below it. However, I am facing an issue where I cannot control the size of the initial image, resulting in misaligned cards. htt ...

Navigating through a collection of elements

I am currently working on my Stripe Checkout Session, attempting to pass an array of product data to the backend node.js server and iterate over it. The object of products I have is structured like this: { products: [ { _id: '62129d518468 ...

Issue with radio button click event not triggering

Whenever I click on a radio button, I want to call a function, but for some reason, it's not working as expected. I found this fiddle that demonstrates exactly what I want, but when I implement it in my code, it doesn't work. Here's a snipp ...

Working with Angular to add various items to an array based on multiple conditions

Currently, I am a beginner in TypeScript and currently involved in an Angular project. As part of my work, I need to make an API call and perform various operations on the received data: public data_Config: IConfig[] = []; this.getService.Data(input).sub ...

Console builds successfully, but encountering issues with building in Docker

Whenever I compile my vite image locally using the following command (found in package.json): "vite_build:dev": "NODE_ENV=test env-cmd -f ./config/.env.dev react-scripts --max_old_space_size=8000 build", everything functions correctly ...

Each item in jquery is undefined

My WebApi is sending back the following JSON object: [ { "Department_Id": 5, "Department_Description": "Test API 1" }, { "Department_Id": 6, "Department_Description": "Test API 2" }, { "Department_Id": 7, "Department_Description": ...

Utilizing ReactJs to Generate a Random Number for Visualization in a Material UI Progress Bar

I am looking to generate a random number for my test functionality in order to display it within a Material UI Progress bar. I have successfully implemented this piece of JavaScript code on JSFiddle, but now I want to integrate it into my React application ...

Passing information from Silverlight to an aspx webpage

Is there a way to send data from my Silverlight application to an aspx page without passing parameters in the URL? I believe using a POST method would be the most appropriate solution, but I am unsure of how to implement it. Can anyone provide guidance o ...

"Looking to swap out URL parameters using JavaScript or jQuery? Here's how you

I've been searching for an effective method to accomplish this task, but I have yet to come across one. Essentially, what I'm looking to do is take a URL like the following: http://localhost/mysite/includes/phpThumb.php?src=http://media2.jupix.co ...

Issue regarding Jquery widget

I am working with a widget that looks like this $.widget("ui.myWidget", { //default options options: { myOptions: "test" }, _create: function () { this.self = $(this.element[0]); this.self.find("thead th").click(fun ...

The ins and outs of duplicating and adding an empty element

Is it possible to add empty html rows dynamically? I want to insert new html rows and clear their contents afterward. To achieve this, I tried using the .html('') method but faced some issues. My implementation looks like the following code sn ...

There seems to be an issue with the function code error when calling it within the

When I attempt to run my code in this way, I encounter a compile time error stating that the expression statement is not an assignment or call... (within the else statement). What am I missing here to get it to work? I've made numerous attempts to ad ...

Prevent page from refreshing on mobile devices using JavaScript

I have been attempting to prevent page refresh on a mobile device through touch scroll events. After researching online, I came across the following method: /* w = flag indicating if pageYOffset was 0 before attempting to scroll below it h = last pageYOffs ...