2012-02-29 71 views
1

我正在使用jquery星級評分插件。在我只有一個EditorFor Textbox之前,它會傳遞用戶鍵入的值,但現在我有5顆星,如何在我的參數中傳遞恆星的值。例如,我評價一位老師4星,我怎麼能通過我提交的其他一切?在MVC3中使用jquery插件

   @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> 

回答

2

你應該將這些<input> s轉換爲EditorTemplate並通過4

標準MVC模式設置name s到@ViewData.TemplateInfo.GetFullHtmlFieldName("")value s到1結合應處理其餘部分。

+0

即時通訊仍然很新,我怎麼能編輯模板?謝謝 – TMan 2012-02-29 02:46:30

+0

或者更好,但我會在editortemplate中放入什麼 – TMan 2012-02-29 03:18:17

+0

http://coding-in.net/asp-net-mvc-3-how-to-use-editortemplates/ – SLaks 2012-02-29 04:26:35