我想在我的asp.net mvc支架式创建页面中通过星级设置<input>
的值
我找到了this html/css star rating form,但是我不知道如何重写它,因为星星选择的值已传递到我的asp.net-mvc模型中
所以,我想知道如何重写此html表单:
<div class="txt-center">
<form>
<div class="rating">
<input id="star5" name="star" type="radio" value="5" class="radio-btn hide" />
<label for="star5" >☆</label>
<input id="star4" name="star" type="radio" value="4" class="radio-btn hide" />
<label for="star4" >☆</label>
<input id="star3" name="star" type="radio" value="3" class="radio-btn hide" />
<label for="star3" >☆</label>
<input id="star2" name="star" type="radio" value="2" class="radio-btn hide" />
<label for="star2" >☆</label>
<input id="star1" name="star" type="radio" value="1" class="radio-btn hide" />
<label for="star1" >☆</label>
<div class="clear"></div>
</div>
</form>
</div>
变成这种剃刀形式:
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.SolutionRating, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SolutionRating, new { htmlAttributes = new { @class = "rating" } })
@Html.ValidationMessageFor(model => model.SolutionRating, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
如果我选择3星,我希望model.solutionRating
属性的值为3。