Thursday, May 30, 2013

Changing a label immediately on a page with Javascript

    I was trying to give status info to users after they had selected one of many options they had available to them, by creating a Status Label and updating it with the action they were performing. i.e.  "Processing File", "Validating File", etc.  However, the label would not update immediately, but only after the processing had occurred. Of course, this was not good.
   I found that I needed to set a timeout, so the browser would have a chance to update the label with the new message.

[code]

       function callProcessValidate(file)
        {
            setStatus("Validating " + file);
            window.setTimeout("ProcessValidate('" + file + "');", 100);
           
        }
       
        function ProcessValidate(file)
        {

             (do some processing)

            setStatus("");  // reset status label back
           
            alert(xmlProcess.responseText);
        }

        function setStatus(vMessage)
        {
            var label;

            label = document.getElementById("lblStatus");
            label.innerText = vMessage;
        }
[/code]

   This will update the label, call the timeout which gives the browser a chance to update the label, and then call the function to do the actual work.

Tuesday, May 7, 2013

Overriding IE Compatibility mode in ASP.NET code

   We have had to set Compatibility mode for some of our programs to work in IE 8-10.  However, some of our newer programs do not work correctly in Compatibility mode. Adding this code to the .aspx file will force Compatibility mode to OFF for this particular program, thus having the program display correctly while Compatibility Mode is turned on in the browser.

[code]


<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

[/code]