Html.EnableClientValidation does, I thought that I would check out that source code to see if there was any kind of generalized mechanism for this. No such luck, I’m afraid. But I did learn a bit more about how
Html.EnableClientValidation works, so I thought I might write that down in case it turned out to be useful someday.
Html.EndForm. Most people don’t call this directly, instead calling
Html.BeginForm inside of a using block, which amounts to the same thing.
Html.EndForm, in MVC 2 does two things:
- Writes a
</form>closing tag. No surprise there.
Therefore, client-side validation will not work if you manually write a
<form> tag rather than directly or indirectly calling
Html.EndForm. However, you can look at its source code and do the same thing yourself if you prefer to write your own
If this second action is a little surprising for a method called "EndForm" the manner in which it accomplishes this task is even more surprising: It calls a function on the
ViewContext type as simply an aggregation of properties containing information relevant to the (ahem) context in which the current page is being rendered. Well, in addition to this,