1

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>

1 Answer 1

2

You should move those <input>s into an EditorTemplate and set the names to @ViewData.TemplateInfo.GetFullHtmlFieldName("") and the values to 1 through 4.

Standard MVC model binding should handle the rest.

Sign up to request clarification or add additional context in comments.

2 Comments

im pretty new to html still, how can i make a editorTemplate? Thanks
You would put the HTML markup that you want to use as the editor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.