开发者

Client validate in MVC 2

开发者 https://www.devze.com 2023-02-04 16:37 出处:网络
I\'m very new in MVC 2, Let say, I have a page with 1 text box and 2 input typed submit, \"back\" and \"next\".

I'm very new in MVC 2,

Let say, I have a page with 1 text box and 2 input typed submit, "back" and "next".

I'm using client validation like this:

<script src="<%=Url.Content("~/Scripts/MicrosoftAjax.js")%>" type="text/javascript"/>
<script src="<%=Url.Content("~/Scripts/MicrosoftMvcAjax.js")%>" type="text/javascript"/>
<script src="<%=Url.Content("~/Scripts/MicrosoftMvcValidation.js")%>" type="text/javascript"/>
.
.
<% Html.EnableClientValidation(); %>
.
.
<input type="submit" name="btnBack" id="btnBack"/>
<input type="submit" name="btnNext" id="btnNext"/>

and validation rule used for that text box is

[StringLength(100, ErrorMessage="This field should be no longer than 100")]

My wish is that vali开发者_运维技巧dation rules will be applied only when I click on Next button. And when I click on Back button, no validation error message will be displayed and form will be posted to server. Is it possible to do that? could you please tell me how?

My problem now is that when I click Back, validation rules are applied and prevent me from posting back to server. Many thanks!

0

精彩评论

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

关注公众号