找到你要的答案

Q:hidden labels via LINQ or HTML Helper

Q:隐藏的标签通过LINQ或HTML辅助

I have been asked to simply include a label tag for both the "username" and "password" form fields on this site. This would be incredibly easy, except I'm not familiar with LINQ. I found the correct syntax, and have added the labels using:

@Html.LabelFor(model => model.UserName)

and

@Html.LabelFor(model => model.Password)

Now I need to make these hidden-field elements, which I don't know how the syntax in LINQ. Any help would be much appreciated!

我被要求简单地包括一个标签标签为“用户名”和“密码”表单字段在此网站上。这将是令人难以置信的容易,除了我不熟悉LINQ。我找到了正确的语法,并增加了标签使用:

@Html.LabelFor(model => model.UserName)

@Html.LabelFor(model => model.Password)

现在我需要把这些隐藏域的元素,我不知道如何在LINQ语法。任何帮助将不胜感激!

answer1: 回答1:

You can use

@Html.HiddenFor(model => model.Username)

and

@Html.HiddenFor(model => model.Password)

你可以使用

@Html.HiddenFor(model => model.Username)

@Html.HiddenFor(model => model.Password)
c#  asp.net-mvc  html5  linq  hidden-field