Maxime Rouiller
Maxime Rouiller

Reputation: 13699

MVC 1 IsValid property equivalent of ModelState.IsValid on the view side

I am trying to display a certain div when an error occur. I'm adding the errors on the controller side and I tried to call the IsValid property of the ViewPage and came up with this error:

Page.IsValid cannot be called before validation has taken place. It should be queried in the event handler for a control that has CausesValidation=True and initiated the postback, or after a call to Page.Validate.

Is there a way to verify that easily?

Upvotes: 2

Views: 194

Answers (1)

Maxime Rouiller
Maxime Rouiller

Reputation: 13699

Alright... forget about it.

I just found it under:

ViewData.ModelState.IsValid

Upvotes: 2

Related Questions