The autopostback feature of ASP.NET/Webform Textbox is not triggered when the onkeyup event contains a "setTimeout" function in Internet Explorer 9

I'm encountering a strange issue specifically on IE 9. The code works perfectly fine in Chrome and Firefox, but not in Internet Explorer. Below is the relevant code snippet:

This problem is occurring in a legacy application built with VS2008. The "corp framework" dynamically defines field masks using JavaScript's `onkeyup` event like this:

Javascript:

function mask(o, f) {
    v_obj = o;
    v_fun = f;

    setTimeout(function() {
    v_obj.value = v_fun(v_obj.value);
    }, 1);
}

ASP.NET HTML:

<asp:TextBox runat="server" ID="TextBox5" AutoPostBack="true" OnTextChanged="TextChanged" />

The mask functionality and postback event are working correctly in all browsers except for IE9. Interestingly, when I remove the `setTimeout` from the JavaScript mask function, the postback works but the masking behavior is lost.

I have observed that setting `AutoPostBack=true` results in an `onchange` event with `setTimeout`. This conflicts with the additional use of `setTimeout` in the mask function. Removing `setTimeout` from the mask enables the postback to work in IE 9.

Rendered HTML:

<input name="TextBox5" type="text" onchange="javascript:setTimeout('__doPostBack(\'MPTextBox5\',\'\')', 0)" onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;" id="MPTextBox5" onkeyup="mask(this, mnum);">

I am struggling to identify the root cause of the issue in IE9 and find a suitable solution.

Answer №1

Unfortunately, Microsoft has decided not to address this bug:

A workaround can be found here:

// To set value for IE without clearing the "changed" flag
this.innerText = val;
// To set value for other browsers
if ( this.value != val ) {
   this.value = val;
}

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

Toggle button color on click by using ng-click on a different button

As a newcomer to Angular, I am facing an issue. I have two buttons - button1 and button2. What I want is that when I click on button1, its color changes from green to red. Then, when I click on button2, the color of button1 should revert back to green. How ...

Tips for implementing a sliding list feature with next and previous buttons:

Currently, I am utilizing a list attribute to display thumbnail images of a YouTube-generated playlist (gdata feed). However, my goal is to enclose the list within a div container and implement next and previous buttons to slide through the playlist images ...

Seeking out information on our family's ancestry

I am currently developing a Family Tree feature for my web application using HTML5 specifications. Despite researching and coming across various JS samples, none seem to meet my specific requirements. I have explored options like JIT, Rafael, and GoJS, but ...

Utilizing the navigator object in React Navigator and expo to enhance component functionality

My React Native application requires a redirection on a specific component. Within my main App.js component, I have the following code snippet: import React from "react"; import { Text } from "react-native"; import { createAppContainer } from "react-nav ...

Javascript malfunctions upon refreshing the div

After updating data with an ajax function and refreshing the div, I encountered an issue where the jQuery elements inside the div break. How can this be resolved? function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]&apo ...

Why isn't $.post functioning properly in any instance?

I've been experiencing issues with my $.post calls throughout my code. Despite not sending requests to different domains, everything is localhosted. My Mac OS X 10.8 automatically defined my localhost alias as ramon.local, and I'm trying to make ...

Display all versions of Excel files within the upload control feature in asp.net

Here is the code I am using for the upload control: <asp:FileUpload ID="FileUpload1" runat="server" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" /> Currently, it only displays Excel (.xlsx) files in the upload control. ...

Can you explain the functionality of the DataTable drawCallback feature?

I'm currently facing an issue where CSS is not being applied to all cells in a DataTable based on their values when using drawCallback(). While the CSS gets applied to some cells, it's inconsistent. You can check out the JsFiddle of my problem he ...

Obtain customer-side logs using Selenium

Currently, I am working with Selenium in C# and am interested in accessing the client-side logs (similar to the console.log function in JavaScript). My approach involves initializing the ChromeDriver and configuring the logging preference to Client: Chrom ...

Incorporate a new substance into a THREEJS Mesh

Is there a way to add a material to an existing mesh without calling the mesh constructor again? I already have a mesh created using the constructor: var mesh = new THREE.Mesh(geometry, material); Now I have created another material in my code: ...

Easily Convert Square Bracket Notation to Dot Notation in JavaScript/Typescript for Quick Replacement

Currently, I am reviewing some code that includes unnecessary square bracket notations. To improve code comprehension, my aim is to transform instances like abc[3]['prop']["subprop"] into abc[3].prop.subprop. I have been able to achiev ...

Why does refreshing a page in AngularJS cause $rootScope values to disappear?

On my local route http://localhost:9000/#/deviceDetail/, there is a controller that handles the view. Before navigating to this view, I set certain variables on the $rootScope (such as $rootScope.dashboards). While on the view, I have access to the dashbo ...

Tips for sharing the scope using module.exports

Within handler.js, I have exported 2 functions: one for initialize() and the other for handle(). The initialize function is used to dynamically load the handler based on the application settings. I have a shared variable called var handler outside the modu ...

How to achieve the functionality of ocibindbyname in JavaScript

I am currently utilizing an HTA page that is coded in JavaScript to monitor various Oracle tables. My goal is to optimize the Oracle query caching by using bind variables, similar to how I implemented it in a PHP environment with this code: $sql = "selec ...

Executing JavaScript in Rails after dynamically adding content through AJAX

Looking for advice on integrating JavaScript functions into a Rails app that are triggered on elements added to the page post-load via AJAX. I've encountered issues where if I include the code in create.js.erb, the event fires twice. However, removing ...

JS problem with decreasing

Within a React component, I have implemented the following method: addWidget = (index) => { let endX = this.state.widgets.reduce((endX, w) => endX.w + w.w, 0) console.log(endX); if (endX === 12) endX = 0 this.setState({ wi ...

Center the image within the div by setting its position to absolute

<div class='img-box'> <img /> //position absolute <img /> //position absolute <img /> //position absolute <img /> //position absolute I am struggling to center the images within this div because of their absolute p ...

Why is it that I am unable to properly encode this URL in node.js?

$node querystring = require('querystring') var dict = { 'q': 'what\'s up' }; var url = 'http://google.com/?q=' + querystring.stringify(dict); url = encodeURIComponent(url); console.log(url); Here is the re ...

Establish a fixed value for a variable without relying on a database

Is it possible to set a permanent value of a variable or flag in VB.Net without saving it to a database? Once a process returns true, I need to set the value and ensure that the program won't run the process again if the value already exists. Using a ...

Creating objects based on interfaces in TypeScript is a common practice. This process involves defining

Within my TypeScript code, I have the following interface: export interface Defined { 4475355962119: number[]; 4475355962674: number[]; } I am trying to create objects based on this interface Defined: let defined = new Defined(); defined['447 ...