本文介绍了手动验证(.NET 4.0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

添加一个CausesValidation设置为false的按钮.单击此按钮时,手动
通过调用Page.Validate()方法来验证页面.然后检查IsValid属性-
并决定该怎么做."

从C#2008开始ASP.NET 3.5 –从新手到专业(ISBN-10(pbk):1-59059-891-1)P. 341

该书适用于.NET 3.5,但是,我正在使用.NET 4.0进行有关Visual Studio 2010的培训.

我尝试使用以下代码,但是,它似乎无法在页面内运行验证:

"Add a button with CausesValidation set to false. When this button is clicked, manually
validate the page by calling the Page.Validate() method. Then examine the IsValid prop-
erty, and decide what to do."

Beginning ASP.NET 3.5 in C# 2008 – from Novice to Professional (ISBN-10 (pbk): 1-59059-891-1) P. 341

The book is for .NET 3.5 however, I''m training on Visual Studio 2010 using .NET 4.0.

I tried using the following code, however, it does not seem to run the validations within the page:

Page.Validate();
        if (!Page.IsValid) lblMessage.Text = "Errors";



那么,我的错误在哪里?

完整代码此处.



So, where is my mistake?

Complete code here.

推荐答案


这篇关于手动验证(.NET 4.0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 10:36
查看更多