limiting edit function in asp.net mvc3 -


i creating application references database using ef in mvc 3. have used scaffolding read/write data , want able allow editing done on database entries, not fields. there way of blocking user editing fields on edit form , therefore database?

since initial question attempted limit edit functionality changing

    <div class="editor-label">         @html.labelfor(model => model.clause)     </div>     <div class="editor-field">         @html.editorfor(model => model.clause)         @html.validationmessagefor(model => model.clause)     </div> 

to use

    <div class="editor-label">         @html.labelfor(model => model.clause)     </div>     <div class="editor-field">         @html.displayfor(model => model.clause)     </div> 

however when saving edit, fields reference displayfor field come out blank. there better way of doing not occur?

many thanks,

chri3

well, quite few solutions.

  1. you can show fields wanna edit in view (not secure, malicious 1 add unwanted fields-values form).

  2. you can update manually fields want in controller.

  3. you can use viewmodels, take properties wanna edit (i advise choose solution).

edit if want have displayed value passed in form, not "visibly editable", you've got pass hidden field.

@html.displayfor(model => model.clause) @html.hiddenfor(model => model.clause) 

but that's solution 1. in answer, worse one.

by way, if don't want edit field, should not mind if comes blank. change way update entities.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -