Reputation: 2711
I have this form on my 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 is that the text of the actual button is the value of Model.Id
.
My goal is to pass the xid
to my controller but I want the text on the button to say something else. How can I do this?
Upvotes: 1
Views: 75
Reputation: 55409
The value
attribute of an <input type="submit">
element specifies both its label and its posted value.
If you want the label and posted value to differ, then you can use a <button>
element instead. Put the label (which can include formatting too!) between the <button>
and </button>
tags:
<button value="@xid" name="xid" class="btn btn-primary">Click Me</button>
Upvotes: 1