I have a dynamic view, this will display any model that has been passed to it.
@model dynamic
@using (Html.BeginForm("Edit", null, FormMethod.Post, new { id="FrmIndex" }))
{
@Html.ValidationSummary(true);
@Html.EditorForModel()
<input type="submit" value="Edit" />
}
Say one of my model is PartyRole
public partial class PartyRole
{
[Key, Display(Name = "Id"]
[UIHint("Hidden")]
public int PartyRoleId { get; set; }
[UIHint("TextBox")]
public string Title { get; set; }
}
I dont want to show Id in edit mode, so I am hiding it in Hidden.cshtml editorfortemplate as below:
@Html.HiddenFor(m => Model)
This is hiding the editor, but not the label "Id". And I cannot use the answers provided here, How to exclude a field from @Html.EditForModel() but have it show using Html.DisplayForModel()
because IMetadataAware requires System.Web.Mvc namespace which I cannot add in my Biz projects that are having the poco model classes. I cannot use [HiddenInput(DisplayValue = false)] also because this is also party of web.mvc
can somebody give a solution??