开发者

How can I add a control to my master page and validate it before the normal page submit events happen?

开发者 https://www.devze.com 2023-02-25 07:32 出处:网络
I would like to add a control to a master page (that will go on almost all the pages in my site). In it I am going to add a custom user control. I would like to be able to have it such that when the u

I would like to add a control to a master page (that will go on almost all the pages in my site). In it I am going to add a custom user control. I would like to be able to have it such that when the user hits the normal submit button the page the control on the master page is validated first and only if it is ok the rest of the normal process takes place. I am looking to do this with a minimal amount of changes to each page. I currently have a custom "Page" class I am using on each webpage that inherits the normal Page class s开发者_开发问答o I can make changes to that as well.


You can use Page.Validate method to explicitly validate your page and check Page.IsValid property to see if page is valid. If Page.IsValid is false the don't execute your code.

If you are not setting ValidationGroup for your submit control, I think the Validation on user control should fire by default.

0

精彩评论

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

关注公众号