How to validate only one .ascx page in an .aspx page while other .ascx pages also registered in the same .aspx page?
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
精彩评论