Skip to content

Instantly share code, notes, and snippets.

@codebeaulieu
Created May 18, 2015 13:44
Show Gist options
  • Save codebeaulieu/8f3a94082469c2396180 to your computer and use it in GitHub Desktop.
Save codebeaulieu/8f3a94082469c2396180 to your computer and use it in GitHub Desktop.
Create.cshtml | programmers.stackexchange.com | How do you handle saving blog tags in MVC?
@model BlogEngine.Models.Post
@using BlogEngine.Models
@{
ViewBag.Title = "Create";
}
<div class="page-content">
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Post</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.Title, htmlAttributes: new { @class = "control-label col-md-2 col-md-offet-3" })
<div class="col-md-7">
@Html.EditorFor(model => model.Title, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Title, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.URL, htmlAttributes: new { @class = "control-label col-md-2 col-md-offet-3" })
<div class="col-md-7">
@Html.EditorFor(model => model.URL, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.URL, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.IntroText, htmlAttributes: new { @class = "control-label col-md-2 col-md-offet-3" })
<div class="col-md-7">
@Html.TextAreaFor(model => model.IntroText, new { htmlAttributes = new { @class = "form-control edit-intro" } })
@Html.ValidationMessageFor(model => model.IntroText, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Body, htmlAttributes: new { @class = "control-label col-md-2 col-md-offet-3" })
<div class="col-md-7">
@Html.TextAreaFor(model => model.Body, new { htmlAttributes = new { @class = "form-control edit-body" } })
@Html.ValidationMessageFor(model => model.Body, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Tags, htmlAttributes: new { @class = "control-label col-md-2 col-md-offet-3" })
<div class="col-md-7">
@Html.HiddenFor(m => m.Tags[0].Id)
@Html.EditorFor(model => model.Tags[0].Name, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Tags, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Author, htmlAttributes: new { @class = "control-label col-md-2 col-md-offet-3" })
<div class="col-md-7">
@Html.EditorFor(model => model.Author, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Author, "", 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>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
</div>
<!-- Modal -->
<div class="modal fade bs-example-modal-lg" id="imgModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Select an Image</h4>
</div>
<div class="modal-body select-body">
@Html.Action("GetImages", "Image", new { area="Admin" })
</div>
<button type="button" class="btn btn-blog-engine select-close" data-dismiss="modal">Select Image</button>
</div>
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment