Hi Mike,
Welcome to MSDN Managed Newsgroup.
This is a known issue of ASP.NET postback with event validation enabled,
and this is not directly related to Firefox. Let me explain the root cause
the possible workarounds.
First, let me explain what is event validation in ASP.NET: this is a
security feature that ensures the postback actions only come from events
allowed and created by the server to help prevent spoofed postbacks. This
feature is implemented by having controls register valid events when they
render (as in, during their actual Render() methods). The end result is
that at the bottom of your rendered <form> tag, you'll see something like
this: <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
value="..." />. When a postback occurs, ASP.NET uses the values stored in
this hidden field to ensure that the button you clicked invokes a valid
event. If it's not valid, you get the exception that you've been seeing.
The problem happens specifically when you postback before the
EventValidation field
has been rendered (i.e., before the page is fully loaded). If
EventValidation is enabled (which it is, by default), but ASP.net doesn't
see the hidden field when you postback, you also get the exception. If you
submit a form before it has been entirely rendered, then chances are the
EventValidation field has not yet been rendered, and thus ASP.net cannot
validate your click.
There are many workarounds for the above mentioned problem, one of them is
that disabling postback until the page is fully loaded as you mentioned:
1. Set enableEventValidation to false:
<pages enableEventValidation="false" ...
2. One way around the problem is to mark the form as disabled and then
enable it in script once the load is complete.
Snippet 1:
========
function enableForm() {
document.getElementById("form").disabled = false;
}
window.onLoad = enableForm();
Snippet 2:
========
function disableElements(elements) {
for (var i = elements.length - 1; i >= 0; i--) {
var elmt = elements
;
if (!elmt.disabled) {
elmt.disabled = true;
}
else {
elmt._wasDisabled = true;
}
}
}
function disableFormElements() {
disableElements(_form.getElementsByTagName("INPUT"));
disableElements(_form.getElementsByTagName("SELECT"));
disableElements(_form.getElementsByTagName("TEXTAREA"));
disableElements(_form.getElementsByTagName("BUTTON"));
disableElements(_form.getElementsByTagName("A"));
}
function enableElements(elements) {
for (var i = elements.length - 1; i >= 0; i--) {
var elmt = elements;
if (!elmt._wasDisabled) {
elmt.disabled = false;
}
else {
elmt._wasDisabled = null;
}
}
}
function enableFormElements() {
enableElements(_form.getElementsByTagName("INPUT"));
enableElements(_form.getElementsByTagName("SELECT"));
enableElements(_form.getElementsByTagName("TEXTAREA"));
enableElements(_form.getElementsByTagName("BUTTON"));
enableElements(_form.getElementsByTagName("A"));
}
Make sure that the variable _form is set to the ASP.net form on the page.
Then just call enableFormElements() and disableFormElements().
Hope this helps. Please feel free to let me know if there's anything else I
can help. Thanks.
Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support
==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box "Tools/Options/Read: Get 300 headers at a time" to
see your reply promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.