开发者

How to validate only one .ascx page in an .aspx page while other .ascx pages also registered in the same .aspx page?

开发者 https://www.devze.com 2023-03-25 15:17 出处:网络
I have some RequiredFieldValidators in both Insert.ascx and Update.ascx. I\'m trying to validate the insert page, but then the fields which are in update page also try to validate, showing the require

I have some RequiredFieldValidators in both Insert.ascx and Update.ascx. I'm trying to validate the insert page, but then the fields which are in update page also try to validate, showing the required field validation message.

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage.Maste开发者_StackOverflow社区r"
    CodeBehind="client.aspx.cs" Inherits="Saver._Default" %>

<%@ Register TagPrefix="ins" TagName="Viewcomments" Src="Insert.ascx" %>
<%@ Register TagPrefix="upd" TagName="brcmsninfo" Src="Update.ascx" %>


Use ValidationGroup for each of your UserControl. ValidationGroup will fire validation only for those controls with the same ValidationGroup value


You need to set the ValidationGroup property on each of your validation controls. See this example

0

精彩评论

暂无评论...
验证码 换一张
取 消