asp.net mvc 3 - Post ID doesn't Work in Form -


i have post define new database entity. after user enters needed values , submits form, insert entity , post same page , display it's id. when enter id area disabled , readonly below, works perfectly.

@using (html.beginform()) {     @html.validationsummary(true)     <fieldset>      id:     @html.textboxfor(model => model.id, new { disabled = "disabled", @readonly = "readonly" })      <p><input type="submit" name="submit" value="create" /></p>     </fieldset> } 

however, when enter readonly in below, insert entity, doesn't view id.

@html.textboxfor(model => model.id, new { @readonly = "readonly" }) 

i have submit in form, uses entities id. however, cannot use disabled here id area, doesn't post id value. can resolve issue?

you can enable disabled field before submitting. so, keep id field disabled. now, enable on submit. ie; if submit form on "mybutton" click, add in document.ready():

$('#mybutton').click(function(e) {     e.preventdefault();     $("#id").removeattr('disabled');     $('form').submit(); }); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -