c# - Give submit button a label that's different from value passed to controller -



c# - Give submit button a label that's different from value passed to controller -

i have form on page:

@using (html.beginform("createcomment", "home", formmethod.post)) { string xid = model.id; @html.textarea("comment", new { @class = "form-control" }) <input type="submit" value="@xid" name="xid" class="btn btn-primary" /> }

my problem text of actual button value of model.id. goal pass xid controller want text on button else. how can this?

the value attribute of <input type="submit"> element specifies both label , posted value.

if want label , posted value differ, can utilize <button> element instead. set label (which can include formatting too!) between <button> , </button> tags:

<button value="@xid" name="xid" class="btn btn-primary">click me</button>

c# html asp.net-mvc button razor

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -