一个UpdatePanel内ASP.NET验证器 [英] ASP.NET Validators inside an UpdatePanel

查看:143
本文介绍了一个UpdatePanel内ASP.NET验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET AJAX的旧版本,由于运行时间的限制,放置一个ASP.NET验证更新面板不工作的内部。是否有一个技巧,使这些工作,或者我需要使用自带的AJAX工具包的ValidatorCallOut控制?

I'm using an older version of ASP.NET AJAX due to runtime limitations, Placing a ASP.NET Validator inside of an update panel does not work. Is there a trick to make these work, or do I need to use the ValidatorCallOut control that comes with the AJAX toolkit?

推荐答案

我怀疑你正在运行的.NET 2.0的原始发布(RTM)。

I suspect you are running the original release (RTM) of .NET 2.0.

直到2007年初验证程序控件不与UpdatePanel的兼容。这是与.NET Framework的SP1解决了。

Until early 2007 validator controls were not compatible with UpdatePanels. This was resolved with the SP1 of the .NET Framework.

问题的根源在于UpdatePanel中可以检测到你的网页标记的变化,但它没有办法正确跟踪脚本。验证程序严重依赖脚本。在一个局部回传,脚本要么干掉了,没有更新,或无法运行时,它们要。

The source of the problem is that UpdatePanel can detect markup changes in your page, but it has no way to track scripts correctly. Validators rely heavily on scripts. During a partial postback, the scripts are either blown away, not updated, or not run when they are meant to.

在早期测试版,微软不得不在UpdatePanel尝试的的什么需要重新渲染或运行脚本。它没有很好地工作,他们不得不把它取出来。

In early betas, MS had the UpdatePanel try to guess what scripts needed to be re-rendered or run. It didn't work very well, and they had to take it out.

要解决眼前的问题,微软在一个名为Validators.DLL新的DLL发布的验证器类的修补版本,并就如何告诉ASP.NET使用,而不是以假乱真这些类的说明。如果谷歌的DLL名称,你应该找到更多的信息。另请参见本博客文章

To get around the immediate problem, Microsoft released a patched version of the validator classes in a new DLL called Validators.DLL, and gave instructions on how to tell ASP.NET to use those classes instead of the real ones. If you Google for that DLL name, you should find more information. See also This blog post.

这是一个停止插科打诨措施,您应该<击>不使用它如果可能的话

This was a stop-gag measure and you should not use it avoid it if possible.

真正解决问题就来了后不久,在.NET 2.0 SP1。微软推出了新的机制,注册在SP1中的脚本,并改变了真正的校验器类来使用机制,而不是旧的。

The real solution to the problem came shortly after, in .NET 2.0 SP1. Microsoft introduced a new mechanism to register scripts in SP1, and changed the real validator classes to use that mechanism instead of the older one.

让我给你的改变一些细节:

Let me give you some details on the changes:

通常,你应该通过页面的方法,如Page.RegisterStartupScript()和Page.RegisterClientScriptBlock()注册的脚本。问题是,这些方法的目的不是为扩展性和UpdatePanel中没有办法监视这些调用

Traditionally, you were supposed to register scripts via Page methods such as Page.RegisterStartupScript() and Page.RegisterClientScriptBlock(). The problem is that these methods were not designed for extensibility and UpdatePanel had no way to monitor those calls.

在SP1中有对称为页Page.ClientScripts一个新的属性的对象。这个对象的方法,以注册是等价(而且在某些方面更好),以原有的脚本。另外,UpdatePanel的可监视这些呼叫,这样,它重新呈现或调用适当时的方法。年长的RegisterStartupScript()等方法已经去precated。他们仍然可以工作,但不是一个UpdatePanel内。

In SP1 there is a new property object on the page called Page.ClientScripts. This object has methods to register scripts that are equivalent (and in some ways better) to the original ones. Also, UpdatePanel can monitor these calls, so that it rerenders or calls the methods when appropriate. The older RegisterStartupScript(), etc. methods have been deprecated. They still work, but not inside an UpdatePanel.

有任何理由(除政治外,我想)不更新您的安装到.NET 2.0 SP1。服务包随身携带重要的修复。

There is no reason (other than politics, I suppose) to not update your installations to .NET 2.0 SP1. Service Packs carry important fixes.

祝你好运。

这篇关于一个UpdatePanel内ASP.NET验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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