Questions tagged [editortemplates]
93 questions
309
votes
5 answers
ASP.NET MVC 3 - Partial vs Display Template vs Editor Template
So, the title should speak for itself.
To create re-usable components in ASP.NET MVC, we have 3 options (could be others i haven't mentioned):
Partial View:
@Html.Partial(Model.Foo, "SomePartial")
Custom Editor Template:
@Html.EditorFor(model =>…

RPM1984
- 72,246
- 58
- 225
- 350
62
votes
1 answer
How to create custom editor/display templates in ASP.NET MVC 3?
I would like to make custom editor templates for different data types in ASP.NET MVC (to use with Html.EditorFor()), including rewriting the existing templates. The ultimate goal is to create a mini-framework where each editor supports javascript…

Vilx-
- 104,512
- 87
- 279
- 422
30
votes
1 answer
In an Editor Template call another Editor Template with the same Model
I have an editor template and within that editor template i want to call another editor template with the same model (i.e. nested), but it does not seem to display.
ie. \EditorTemplates\Template1.cshtml
@model foo
// insert code here to edit the…

tkerwood
- 1,875
- 16
- 26
24
votes
3 answers
Returning an EditorTemplate as a PartialView in an Action Result
I have a model similar to this:
public class myModel
{
public ClassA ObjectA {get; set;}
public ClassB ObjectB {get; set;}
}
In my main view, I have tags similar to this:
<%=Html.EditorFor(m =>…

Mike Therien
- 928
- 3
- 10
- 25
21
votes
3 answers
Problem with MVC EditorFor named template
I have what appears (to me anyway) to be a strange problem...
I created a simple editor template for a SelectListItem (SelectListItem.cshtml in the ~/Views/Shared/EditorTemplates folder), for example:
- 4,385
- 5
- 41
- 74

Neilski
15
votes
3 answers
Can I Add to the Display/EditorTemplates Search Paths in ASP.NET MVC 3?
I have a standard set of templates for my mvc projects which I want to keep as an external folder in my source control (SVN)
This means that I cannot put any project specific files in this folder as it will be committed to the wrong place..
.. and…

Anthony Johnston
- 9,405
- 4
- 46
- 57
12
votes
5 answers
ASP.NET MVC 2 - Html.EditorFor a nullable type?
I have two editor templates: one for decimal, and one for decimal? (nullable)
But when I have a nullable decimal in my model, it tries to load the normal decimal editor:
<%: Html.EditorFor(model => model.SomeDecimal )%>
<%: Html.EditorFor(model =>…

JK.
- 21,477
- 35
- 135
- 214
11
votes
1 answer
When do I use View Models, Partials, Templates and handle child bindings with MVC 3
new to mvc3, i have a few questions, would appreciate if someone could answer/provide links:
When should I use View Models? Is it not recommended to use the domain? I find that my view models are copies of my domain objects, and don't see the…

newbie_86
- 4,520
- 17
- 58
- 89
10
votes
1 answer
Custom Asp.net MVC 3 editor template not getting used
I have an MVC 3 web app that uses Razor view engine. I would like to extend default editor templates so I'd like to add additional HTML5 attributes to input elements like autofocus.
I'm using AdditionalMetadataAttribute to specify certain properties…

Robert Koritnik
- 103,639
- 52
- 277
- 404
10
votes
1 answer
get value from custom attribute in editor template
at the moment I have this:
in the ViewModel:
[MyCustom(Foo = 23)]
public int CountryId { get; set; }
in the Editor template:
<%= Html.TextBox("", Model) %>
how can I get the value (Foo=23) from my custom attribute (MyCustom) into the editor…

Omu
- 69,856
- 92
- 277
- 407
9
votes
3 answers
ASP.NET EditorTemplate DropdownList
Every time I add a new App It creates a new AppCategory. I am seriously screwing this up somehow
code first entity framework objects
public class AppCategory
{
public int ID { get; set; }
public string Name { get; set; }
public…

MarkKGreenway
- 8,494
- 5
- 34
- 53
8
votes
2 answers
ASP.Net MVC 3 - Client side unobtrusive validation for Editor Templates
I am new to ASP.Net MVC 3, facing some issues while trying to implementing client side unobtrusive validation for a editor template I have created for showing date in a custom way.
UI
I need to show date in a three texbox UI format as
I have put…

Shravan
- 191
- 1
- 7
7
votes
5 answers
How to create a editor template for DateTime with 3 fields?
I want to create an editor template for DateTime, I need 3 separated fields:
(DropDown) Day | (DropDown) Month | (DropDown) Year
How and where do I create this file? And what do I need to do to turn these 3 fields into a single DateTime…

BrunoLM
- 97,872
- 84
- 296
- 452
7
votes
1 answer
Netbeans: C/C++ file-template variables documentation needed
I'm looking for a faq or overview on C/C++ template-file variables in Netbeans (7.0).
(Not to be confused with the template technique). Those you see under Tools > Templates > C++ templates.
e.g.
%<%CLASSNAME%>% %<%DEFAULT_HEADER_EXT%>% …

Kirschi
- 1,088
- 3
- 12
- 32
6
votes
1 answer
How do I use editortemplates in MVC3 for complex types?
I have two classes, Vat and Product. Product has a property of IVat. I am trying to use editor templates in MVC to display a dropdown list of all the Vat objects when creating/editing a Product. For the dear life of me I cannot get this…

Pieter
- 2,188
- 20
- 27