Monday, March 12, 2012

Would like to disable validation for entire page

I'd like to conditionally enable or disable the page validation. I was
thinking something like;

Enummerate through all controls...if control is validation control type,
then control.ControlToValidate = ""

I think that would work but I don't know how to ennumerate through each
control and check to see if it is a validatior control or not. Also, would
this method even work?

Thanks,
MikeI found a solution, Here is what I did...

Dim ctl As Control
Dim pnl As Control
pnl = Page.FindControl("myPanel")
For Each ctl In pnl.Controls
If ctl.GetType.BaseType.Name.ToString =
"BaseValidator" Then
ctl.Visible = False
End If
Next

"Mike Hnatt" <dog4@.gladstone-inc.com> wrote in message
news:vq0i4fh3450p10@.corp.supernews.com...
> I'd like to conditionally enable or disable the page validation. I was
> thinking something like;
> Enummerate through all controls...if control is validation control type,
> then control.ControlToValidate = ""
> I think that would work but I don't know how to ennumerate through each
> control and check to see if it is a validatior control or not. Also,
would
> this method even work?
> Thanks,
> Mike
Check out this article for looping through controls,
http://www.extremeexperts.com/Net/A...ghControls.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com

"Mike Hnatt" <dog4@.gladstone-inc.com> wrote in message
news:vq0i4fh3450p10@.corp.supernews.com...
> I'd like to conditionally enable or disable the page validation. I was
> thinking something like;
> Enummerate through all controls...if control is validation control type,
> then control.ControlToValidate = ""
> I think that would work but I don't know how to ennumerate through each
> control and check to see if it is a validatior control or not. Also,
would
> this method even work?
> Thanks,
> Mike

0 comments:

Post a Comment