English 中文(简体)
MVC @Html.Display()
原标题:MVC @Html.Display()

我有这样的想法:

 <input type="text" name="TerrMng" id="TerrMng"/>  

页: 1 以上用@Html表示。 显示器

I Trial using: @Html.Display(“TerrMng”, TerrMng)

but was not successful. Note that I like to use @Html.Display but not sure how to translate the ID value so that it shows up.

最佳回答

如果你只是想显示数据,而不允许用户篡改信息,那么就应当这样做。

@Html.DisplayFor(m => m.TerrMng);

<><>Edit>:

what-is-the-html-displayfor-syntax-for 另一问题是关于停滞不前的问题,可以给予你更多的指导。

<><>Edit>:

TerrMng在Load页上不存在,因此你不能以这种方式使用<>Html.Display。 你们需要创建这一机制,并以从金库获得的价值来弥补其价值。 在这种情况下,你必须做以下工作:

传真

 @Html.Display("TerrMng"); // This creates the label with an id of TerrMng

页: 1 学历

 $("#TerrMng").val(TerrMng); // This puts the value of the javascript variable into the label
问题回答

你们可以尝试这方面的事。 这不是确切的,但你可以找到某种想法。

@Html.TextBoxFor(yourmodel => model.yourModelFieldname, null)

@Html.Display(>>, 而不是@Html.DisplayFor(>>>,如果您的模型在汇编时间时不知道,或者如果你喜欢用斜体,而不是用强体字进行工作的话。 例如,这2项是等同的(因为你的模式是某些类别):

@Html.DisplayFor(m => m.MyProperty)

and

@Html.Display("MyProperty")

But the additional cool feature of the Display() method is that it can also do the lookup in the ViewData, and not just in your Model class. For example, here is a way to display the HTML for the property on a random object, given that we know it has a property named "Blah" (the type of the object doesn t really matter):

@{ ViewData["itsawonderfullife"] = SomeObject; }
<div>@Html.Display("itsawonderfullife.Blah")</div>

This way, we are telling HtmlHelper to look into the ViewData, instead of our Model, and to display the property Blah of a given SomeObject.





相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签