9

Html.EditorForModel and Hiding Element Edit

 3 years ago
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.
neoserver,ios ssh client

Html.EditorForModel and Hiding Element Edit

advertisements

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

Let's say I download an html page along with all its css files (e.g. with curl) So I have some html code, some css in head, in tags, and some css from files. Is there a tool I can use to, e.g. get the color and font-size of that character at position

iframe and hiding elements

Is there anyway to control elements shown in an iframe? for example I am loading in a page in an iframe from google docs viewer which has controls for the user to navigate but I don't want these shown in my iframe...is there anyway to control this if

Is there a validable way to use HTML tags and input elements and the entry has no identifier?

I'm using Jquery Mobile for an application, which has a login popup on every page. The problem is, Jquery Mobile will always have at least 2 pages in the DOM, so I will have two popups and login forms in the DOm, forcing me to find a way to avoid dup

WPF: Showing and Hiding Items in an ItemsControl with Effects

I've been using this great article as a basis for showing and hiding elements with a transition effect. It works very neatly in that it lets you bind the Visibility property just as normal, then define what happens when the visibility changes (e.g. a

jQuery to change the element attributes and return the edited html source?

Actually what i'm doing is to find the <img> image tags and get its src attribute to change them. I already got upto this point but the problem more is: To get the edited the html source back (to put into the database.) To say more brief & clear

html - CSS: How to vertically align text and form elements in a label label?

I have a <label> in my html document, where I have some text and form elements in it. How can I vertically align them in middle? <label> Show <select name="list_length" size="1" aria-controls="admin_id"> <

the use of html tag and elements in the text box causes an error: a potentially dangerous Request.Form was detected from the client

i want to convert my html file to pdf in that process i took all html tags and elements into an asp textfield on button click its giving the above error code is code.aspx <asp:TextBox ID="TxtHtmlCode" CausesValidation="false" runat=

Showing and hiding the element using css does not work

I have an unordered list element contains list of elements like this. <div class="menu"> <ul> <li class="menu-x">x1</li><li class="menu-x">x2</li><li class="menu-x">x3</l

JavaScript retrieves h1 elements in the HTML document and updates unique identifiers

I have a legacy html document containing h1 elements which don't have ids. What I would like to achieve is to be able, using JavaScript, to get all h1(s) and then add to each a unique ID. I have searched but could not find a solution that works.Try g

Edit the HTML file and replace the strings.How?

I've a HTML file named "aud.html". I want to edit this file to search for a particular strings present in $stream_name variable and replace the same in the html file. below is my code, but it doesn't work. Any issue? $RESULTS_FILE = "/aud.h

How to edit an html file and assign it to all other files?

I am currently in the process of building my website and sometime I want to change the link in the navigation bar and then I have to change it in every single html document and I have about 30... Is their a script or anything that I can use to only e

Edit html content and URL without reloading the page

I see many websites such as gitHub changing it's html content and URL without refreshing pages. I find one possible way to do this in HTML Histroy API. Here is the code. HTML <div class="container"> <div class="row"> <ul

Hide and show elements of tablerow with jquery

I have a simple function that shows and hides elements if a user clicks a link. It's currently set up as such: $('div.box table a').click(function (e) { stopEvent(e); var self = $(this); if ($("#" + self.text()).css('display', 'none')) { $("

Problem with fluid and reactive layout and floating elements

I'm designing a basic, two-column fluid responsive layout that linearizes for mobile-- as depicted in my attached diagram-- using floated elements; and I'm having an issue with certain elements dropping, as can be viewed in the fiddle I've set up her

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK