Reputation: 4122
I'm using a jquery star rating plugin. Before I would just have a EditorFor Textbox and that would pass in the value of what ever the user would type but now I have 5 stars, how can pass the value of stars in my parameter. For example is i rate a teacher 4 stars, how can/would I pass that 4 in with everything else I'm submitting?
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Teachers Ratings Wall</legend>
<div class="editor-label">
@Html.LabelFor(model => model.StarRating)
</div>
<div class="editor-field">
@*@Html.EditorFor(model => model.StarRating)*@
@Html.ValidationMessageFor(model => model.StarRating)
<input name="star1" type="radio" class="star"/>
<input name="star1" type="radio" class="star"/>
<input name="star1" type="radio" class="star"/>
<input name="star1" type="radio" class="star"/>
<input name="star1" type="radio" class="star"/>
</div>
<div class="editor-label">
@Html.LabelFor(model => model.PostComment)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.PostComment)
@Html.ValidationMessageFor(model => model.PostComment)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.PostDate)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.PostDate)
@Html.ValidationMessageFor(model => model.PostDate)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Teacher)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Teacher)
@Html.ValidationMessageFor(model => model.Teacher)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
Upvotes: 1
Views: 738
Reputation: 887877
You should move those <input>
s into an EditorTemplate and set the name
s to @ViewData.TemplateInfo.GetFullHtmlFieldName("")
and the value
s to 1 through 4.
Standard MVC model binding should handle the rest.
Upvotes: 2