您的位置:首页 - MVC
@Html.LabelFor
LabelFor使用了模型类中相应的DisplayName属性

模型类:
public class LoginModel
{
public LoginModel()
{
LoginName = HttpContext.Current.User.Identity.Name;
}

[Required]
[DisplayName("用户名:")]
public string LoginName
{ get; set; }

[Required]
[DataType(DataType.Password)]
[DisplayName("密码:")]
public string Password
{ get; set; }

///
/// 用户验证结果
///

public string ValidateResult
{ get; set; }
}



.cshtml页面:

<table width="460" border="0" align="center" >

<tr>
<td>

</td>
<td width="52">
<%: Html.LabelFor(m => m.LoginName) %>
</td>
<td width="187">
<%: Html.TextBoxFor(m => m.LoginName) %>
</td>
</tr>
<tr>
<td>

</td>
<td>
<%: Html.LabelFor(m => m.Password) %>
</td>
<td>
<%: Html.TextBoxFor(m => m.Password) %>
</td>
</tr>
<tr>
<td>

</td>
<td>

</td>
<td>
<input type="submit" value="登 陆" style="width: 60px; background: url(../../../Content/Images/Button/btn57-21.jpg) no-repeat;
border: none; color: #000;" />
<input type="reset" value="取 消" style="width: 60px; background: url(../../../Content/Images/Button/btn57-21.jpg) no-repeat;
border: none; color: #000;" />
</td>
</tr>
</table>
本站导航
相关文章
柯乐义 Copyright© keleyi.com