Html.EditorForModel and Hiding Element Edit
source link: https://www.codesd.com/item/html-editorformodel-and-hiding-element-edit.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Html.EditorForModel and Hiding Element Edit
I'm using the following code to render an editor for my model using ASP.NET MVC 3, it works perfect, except for I don't want the user to see or edit the "Id" field in my object.
<% using (Html.BeginForm())
{ %>
<%: Html.ValidationSummary(true, "Your input has errors, please correct and try again") %>
<%: Html.EditorForModel(Model)%>
<input type="submit" value="Update" />
<% } %>
In my model for the ID Field I have the following
[Display(AutoGenerateField = false)]
public int Id{ get; private set; }
Which granted is what I thought would work based on the description of the "AutoGenerateField" parameter. However this isn't working. I don't want to have to build the whole editor just for this one little oddity....
Use [ScaffoldColumn(false)]
to hide fields
Related Articles
Command line tool for interpreting HTML / CSS and obtaining element styles
iframe and hiding elements
Is there a validable way to use HTML tags and input elements and the entry has no identifier?
WPF: Showing and Hiding Items in an ItemsControl with Effects
jQuery to change the element attributes and return the edited html source?
html - CSS: How to vertically align text and form elements in a label label?
the use of html tag and elements in the text box causes an error: a potentially dangerous Request.Form was detected from the client
Showing and hiding the element using css does not work
JavaScript retrieves h1 elements in the HTML document and updates unique identifiers
Edit the HTML file and replace the strings.How?
How to edit an html file and assign it to all other files?
Edit html content and URL without reloading the page
Hide and show elements of tablerow with jquery
Problem with fluid and reactive layout and floating elements
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK