在Firefox验证客户端code的ASP.NET渲染破 [英] ASP.NET broken rendering of Validation client side code in Firefox

查看:134
本文介绍了在Firefox验证客户端code的ASP.NET渲染破的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一次一直是我难倒的。它很容易复制虽然是相当模糊的问题。这是约,因为我是做网页上的一些JavaScript的工作但还利用了验证控件,ASP.NET提供。

一些细节前面:使用基于Windows Vista的开发机器的3.5框架和IIS 7,我也有一个运行Windows Server 2003,也与3.5框架,但运行的QA机IIS 6

以一个页面用一个简单的文本框,验证控制和按钮来提交他们。例如:

 < ASP:文本框ID =TextBox1的=服务器>< / ASP:文本框>
< ASP:的RequiredFieldValidator ID =RequiredFieldValidator1=服务器的ErrorMessage =TEXT是必需的ControlToValidate =TextBox1的>< / ASP:&的RequiredFieldValidator GT;
< ASP:按钮的ID =btnSubmit按钮=服务器文本=提交/>

简单的ASP.NET验证控件code这里...这里的想法是,客户端验证code是必填字段生成回发不这样做,除非在文本框中有一个字段。如果浏览器不支持客户端脚本,那么ASP.NET将使用Page.IsValid属性赶上它在服务器端。

当我运行这个从我的基于Windows Vista的开发机,是您在IE和Firefox和生成的客户端脚本code 工作就好了。

当我从基于WIN2003-QA机中运行,也为这两个浏览器生成的客户端code为验证程序控件。验证code IE浏览器工作正常...但是不会作为Firefox的工作。当提交按钮是pssed(一个空的文本框)$ P $,客户端code似乎被忽略,回发执行。现在验证错误被捕获服务器端 - 但我想的知道为什么它不是摆在首位的工作客户端

这里有趣的怪癖是,如果我把页面源视图下的Firefox从开发计算机(即作品的)和QA机(即没有一个),并比较它们 - 在客户端验证code是显着不同。

什么改变来获得客户端验证code在Firefox工作的质量保证机器的想法?

更新:有一些意见,要求查看生成的源代码。我已经保存了开发和QA源作为.htm文件和压缩它们。您可以在 http://www.optsolutions.com/testvalidation.zip

解决方案

检查你的web.config的xhtmlconformance并确​​保它没有被设置为遗产。

<一个href=\"http://aspadvice.com/blogs/rbirkby/archive/2006/11/01/Client_2D00_side-validation-in-Firefox.aspx\" rel=\"nofollow\">http://aspadvice.com/blogs/rbirkby/archive/2006/11/01/Client_2D00_side-validation-in-Firefox.aspx

This one has been a stumper for me. Its very easy to duplicate though a rather obscure issue. It came about as I was doing some javascript work on a web page yet also make use of the validation controls that ASP.NET provides.

Some specifics up front: using a Vista-based development machine with the 3.5 framework and IIS 7. I also have a QA machine that is running windows server 2003, also with the 3.5 framework but running IIS 6.

Take a page with a simple TextBox, Validation Control, and button to submit them. For example:

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Text is Required" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>  
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />

Simple ASP.NET validation control code here ... The idea here is that client-side validation code is generated for the required field and a postback is not done unless the text box has a field. If the browser does not support client-side scripting, then ASP.NET will catch it on the server side using the Page.IsValid property.

When I run this from my Vista-based development machine, the client-side scripting code is generated for both IE and Firefox and works just fine.

When I run from the win2003-based QA machine, client side code for the validator controls is also generated for both browsers. The validation code for IE works fine ... but does Not work for Firefox. When the submit button is pressed (with an empty text box), the client-side code appears to be ignored and a postback performed. Now the validation error is caught server side - but I want to know why its not working client side in the first place.

The interesting quirk here is that if I take page source views under Firefox from the Development machine (the one that works) and the QA machine (the one that doesn't) and compare them - the client side validation code is dramatically different.

Ideas on what to change to get the client side validation code to work in Firefox with the QA machine?

UPDATE: Had a few comments asking to see the generated source. I've saved the Dev and QA source as .htm files and zipped them up. You can get them at http://www.optsolutions.com/testvalidation.zip

解决方案

Check your web.config for xhtmlconformance and make sure it is not set to legacy.

http://aspadvice.com/blogs/rbirkby/archive/2006/11/01/Client_2D00_side-validation-in-Firefox.aspx

这篇关于在Firefox验证客户端code的ASP.NET渲染破的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆