I have the following code which should update a label to say “please wait..”, then run a function, and then update the label again to say it has completed:
<asp:Button ID="Button1" runat="server" Text="Upload"
onclientclick="document.getElementById('errorMessage').innerText='Please Wait...';"
onclick="Button1_Click" />
This works fine in IE, but not in Firefox.
When I run it in Firefox the label does not change until the process completes.
Is there a way to force the javascript to update the page before running the C# function?
The
innerTextproperty is a proprietary Internet Explorer feature. In Firefox and other DOM compatible browsers, usetextContent(link).The following code will test to see which property is supported by the browser and use the appropriate one:
If your site will involve a lot of JavaScript, I strongly recommend using a 3rd-party library such as jQuery that takes care of these browser incompatibilities for you.