我在MVC編程一個新的asp.net.I在mvc4創建的應用程序與實體framework.My的問題是,我無法驗證輸入entry.It總是返回true型號state.isvalid總是返回true
。我的Index.aspx代碼在這裏
<% using (Html.BeginForm("Validate","Transport")){%>
<table id="tblogin">
<tr>
<th style="text-align:right">Email</th>
<td>
<%=Html.TextBox("email") %>
<%= Html.ValidationMessage("email", "*")%>
</td>
</tr>
<tr>
<th style="text-align:right">Password</th>
<td>
<%=Html.TextBox("pswd") %>
<%= Html.ValidationMessage("pswd", "*")%>
</td>
</tr>
<tr>
<th></th>
<td align="right"><input style="" type="submit" value="login" ></td>
</tr>
</table>
<%} %>
我的模型類是這裏
[Required]
public string email { get; set; }
[Required]
public string pswd { get; set; }
debugg圖像
不清楚你的要求。顯示您的控制器代碼,瞭解您發佈的方法。 –
你的'ActionResult Validate()'沒有收到任何參數,它應該接收你的視圖的viewmodel,以便你可以驗證它。 – zed