我正在使用jquery星级评分插件。在我有一个EditorFor Textbox之前,它会传递用户输入的值,但现在我有5颗星,我怎么能在我的参数中传递星号的值。例如,我评价一位老师4星,我怎么能/我将其中的4个传递给我提交的其他内容?
@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>
答案 0 :(得分:2)
您应该将这些<input>
移到EditorTemplate中,并将name
设置为@ViewData.TemplateInfo.GetFullHtmlFieldName("")
,将value
设置为1到4。
标准的MVC模型绑定应该处理其余部分。