Edit form structure

Simple Edit form structure:

@model ViewModelName
@{
ViewBag.Title = "My title";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>@ViewBag.Task @ViewBag.Title</h2>

@using (Html.BeginForm(“Edit”, “ControllerName”, FormMethod.Post, new { @role = “form”}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)

@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.PropertyId)
<div class=”row form-group”>
<div class=”col-sm-4″>
@Html.LabelFor(model => model.PropertyName)
@Html.DisplayFor(model => model.PropertyName)
</div>

<div class=”col-sm-4″>
@Html.LabelFor(model => model.SortOrder, new {@class = “control-label”})
@Html.EditorFor(model => model.SortOrder)
@Html.ValidationMessageFor(model => model.SortOrder)

</div>
<div class=”col-sm-4″>
@Html.LabelFor(model => model.Active)

@Html.EditorFor(model => model.Active)
@Html.ValidationMessageFor(model => model.Active)
</div>
</div>

<fieldset>
<legend></legend>
<div class=”row form-group”>

vdiv class=”col-sm-6″>
@Html.LabelFor(model => model.Name, new {@class = “control-label”})

@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class=”col-sm-6″>
@Html.LabelFor(model => model.Description, new {@class = “control-label”})

@Html.EditorFor(model => model.Description)
@Html.ValidationMessageFor(model => model.Description)

</div>

</div>
</fieldset>

<div class=”row form-group”>
<div class=”col-sm-12″><input type=”submit” value=”Save” />
</div>

</div>

<div class=”row form-group”><div class=”col-sm-12″>
@Html.ActionLink(“Back to list”, “Index”)</div>
</div>

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s