I'm currently building the Admin back-end for a website in ASP.NET MVC.
In an ASP.NET MVC application, I've started using the 'EditorFor' helper method like so:
<div id="content-edit" class="data-form">
<p>
<%= Html.LabelFor(c => c.Title) %>
<%= Html.TextBoxFor(c => c.Title)%>
</p>
<p>
<%= Html.Label...
So far we can use Html.EditorFor() to dynamically render the appropriate template for a datatype - e.g. string, int, or a custom type, say 'Address'.
Now I want to use EditorFor() to render a 'Parent' field. I want a drop-down containing every row, and the user picks a parent from this drop-down.
The 'Parent' template has access to the...
Hi,
You can provide alternate templates for individual types, but is it possible to override the template that wraps the label, field and validation up.
Change:
<div class="editor-label"><label for="Content">Content</label></div>
<div class="editor-field"><input class="text-box single-line" id="Content" name="Content" type="text" valu...
Say you have this:
public class ShoppingCart {
public IList<CartItem> cartItems {get; set; }
}
And you do this to render the class:
<%= EditorFor( m => m.ShoppingCart, "ShoppingCart") %>
How would you do the EditorFor( ??, "CartItem") in the ShoppingCart.ascx? I would think it would look something like this:
<% foreach( CartI...
Hey guys
Just wondering how do I mimic the following using attributes...
<%= Html.EditorFor(x => x.SportProgramIdList, "FormMultiSelectDropDownList", "SportProgramIds")%>
I know I can specify the template by using [UIHint("FormMultiSelectDropDownList")] but I am left with the problem with how to set the name...
Cheers
Anthony
...
In the MVC RC 2 docs, we find:
Expression-based helpers that render input elements generate correct name attributes when the expression contains an array or collection index. For example, the value of the name attribute rendered by Html.EditorFor(m => m.Orders[i]) for the first order in a list would be Orders[0].
Anyone care to lin...
I have the following classes in my Model:
public abstract class Entity : IEntity
{
[ScaffoldColumn(false)]
public int Id { get; set; }
[Required,StringLength(500)]
public string Name { get; set; }
}
and
public class Model : SortableEntity
{
[Required]
public ModelType Type { get; set; }
[ListRequired]
...
I am getting some unexpected behavior from Html.EditorFor().
I have this controller:
[HandleError]
public class HomeController : Controller
{
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Lister()
{
string[] values = { "Hello", "world", "!!!" };
return View(values);
}
[AcceptVerbs(HttpVerbs.Post...
Hi
I have a View that contains a usercontrol. The usercontrol is rendered using:
<% Html.RenderPartial("GeneralStuff", Model.General, ViewData); %>
My problem is that the usercontrol renders nicely with values from the model but when I post values edited in the usercontrol they are not mapped back to Model.General. I know I can find ...
When calling Html.EditorFor(m => m), where m is a public class with public properties, a hidden input and a label are displayed for properties with the [HiddenInput] attribute.
How can I hide the label without making it private or creating an editor template?
Example
public class User
{
[HiddenInput]
public Guid ID { get; s...
I have got an Entity model which contains a collection of Message objects which are of the type Message which has several properties, including content, MessageID, from, and to.
I have created an EditorTemplate for type Message, however, I cannot get it to display the contents of the Messages collection.
There are no errors, but nothin...
I have following problem. In my view model I defined some list properties as follows:
public class BasketAndOrderSearchCriteriaViewModel
{
List<KeyValuePair> currencies;
public ICollection<KeyValuePair> Currencies
{
get
{
if (this.currencies == null)
this.currencies = new List<KeyV...
<%= Html.EditorFor(product => product.Name) %>
I need the generated output to have autocomplete="off" attribute set.
What I'm missing?
Edit:
I'm looking an extension method for EditorFor that accepts key/value dictionary for attributes, so I can call it like this: <%= Html.EditorFor(product => product.Name, new { autocomplete = "off"...
For a project I'm working I've been asked to redirect an editor template to its display template based on metadata that is provided with the model.
Now I was looking at a way to do it before it hits the editor template but that seems to cause more issues than it is worth, at least with how the system has been architected.
The simplest ...
I've got a model which contains a List of QuestionEditModel for which I want to use an EditorFor.
Normally, I would just call EditorFor on the collection and MVC will do the rest. However, I need the individual QuestionEditModel to use different EditorTemplates depending on the value of a field within the object.
I would've thought tha...
ok i've defined a shared editor for string like the following
<%@ Control Language="C#"
Inherits="System.Web.Mvc.ViewUserControl"
%>
<%= Html.LabelFor(model => model) %>
<%= Html.TextBoxFor(model => model) %>
<%= Html.ValidationMessageFor(model =>
model) %>
now i'm calling the custom editor like ...
I'm trying to create a form which will be used by clients to place an order for variable amount of models. It's similar to example from Steve Sanderson's blog, but I'm not using any javascript - I just have multiple submits in my form.
Everything works fine, I can add as many items as I want, but when I delete an item always the last on...
Why can't I pass in html attributes to EditorFor()? eg;
<%= Html.EditorFor(model => model.Control.PeriodType,
new { disabled = "disabled", readonly = "readonly" }) %>
I don't want to use metadata
Update: The solution was to call this from the view :
<%=Html.EditorFor( model => model.Control.PeriodEndDate, new {Modifiable=mode...
I would like to control or customise the output generated by DisplayFor and EditorFor so it doesn't render the default html css tags for example:
.......
I would like this to be for all views not just a type or system type? And what is the simplest solution?
Any help would be appreciated.
...
I have an EditorFor Template for a Model Role as below. I also have EditorFor for Date which works fine when I use EditorFor directly from View but when I have EditoFor inside an editor for it doesn't work. Any idea?
Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl[ucsrManagementSystem.Models.ContactsInMailingListsViewMode...