Creating Create View

As we did regularly, we need to call the model by using

@model PlaylistGenreMvc.Models.GenreModel

Remember about Html.BeginForm method?

Yes, we will use it whenever we perform CRUD method in form application.

In this project, other new HTML helper codes being introduced. The ValidationMessageFor() method will only display an error, if you have configured the DataAnnotations attribute to the specifed property in the model class.

The final code shown below.

@model PlaylistGenreMvc.Models.GenreModel
@{
    ViewBag.Title = "Create";
}
<h2>Create</h2>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>PublisherModel</legend>
        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
}

results matching ""

    No results matching ""