English 中文(简体)
@Html.EditorForModel(Model)如何真正发挥作用? (ASP.NET)
原标题:How the @Html.EditorForModel(model) really works ? ( ASP.NET )

How the @Html.EditorForModel(Model.ElementAt(i)) really works, if "model.count()" is 5. Why do I get a dimension of "5*5" elements?

@model List<model>
@for (int i = 0; i < Model.Count();i++ )
{                
    @Html.EditorForModel(Model.ElementAt(i))                
}

实际给我5个要素的唯一尝试是:

@model List<model>

@Html.EditorForModel(Model)                

In the template for model I am using Javascript to change a value of the model.Numbers, using a "GetElementById("NumbersX")":

 @Html.TextBoxFor(m => m.Numbers, new { id = "NumbersX" })

是否有任何人知道执行这项任务的更好方式,或已经履行的职能?

问题回答

<代码>EditorForModel输出整个模型的编辑。

Your model has five elements, so one "whole editor" is five elements.
You call it five times, so you get 5x5 elements.

或许,请打电话EditorFor,而不是EditorForModel

@Html.EditorFor(m => m.ElementAt(i)) 

但是,将不会像你预期的那样发挥作用。 然而,由于你有一份名单作为你的模式,你可以适当开展工作:

@Html.EditorFor(m => m[i]) 

http://msdn.microsoft.com/en-us/library/ff406445.aspx” rel=“nofollow noreferer”>overload 你打电话接受 ViewData作为其参数。 您通过一个叫<>EditorFor的斜体,而“lambda”只是什么。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签