I used Asp.netMVC and created a view but CreateView page does not get styles and does not send parameters to the database but EditView and DeleteView work.
View Code Iadded CkEditors code under the csHtmls code
@model My_E_Shop.Models.Pages
@{
ViewBag.Title = "Create" + Server.HtmlDecode(Html.DisplayNameFor(model => model).ToString());
}
<h2>Create@Html.DisplayNameFor(model => model)</h2>
@using (Html.BeginForm("Create", "Pages", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true)
@Html.HiddenFor(model => model.PageID)
@Html.HiddenFor(model => model.CreateDate)
@Html.HiddenFor(model => model.PageSee)
<div class="form-group">
@Html.LabelFor(model => model.PageTitle, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.PageTitle)
@Html.ValidationMessageFor(model => model.PageTitle)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ShortDescription, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ShortDescription)
@Html.ValidationMessageFor(model => model.ShortDescription)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PageText, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.PageText)
@Html.ValidationMessageFor(model => model.PageText)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ImageName, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.Kendo().Upload().Name("imgUp")
@Html.ValidationMessageFor(model => model.ImageName)
</div>
</div>
<div class="form-group" id="buttons">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-primary" />
@Html.ActionLink("Back", "Index")
</div>
</div>
</div>
}
@section Scripts
{
<script src="/ckeditor/ckeditor.js"></script>
<script src="/ckeditor/adapters/jquery.js"></script>
<script>
$(function () {
$('#PageText').ckeditor();
});
</script>
}
Controller Code
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "PageID,PageTitle,ShortDescription,PageText")]
Pages pages, HttpPostedFileBase imgUp)
{
if (ModelState.IsValid)
{
if (imgUp != null)
{
if (CheckContentImage.IsImage(imgUp))
{
pages.ImageName = Guid.NewGuid().ToString().Replace("-", "") +
Path.GetExtension
(imgUp.FileName);
imgUp.SaveAs(Server.MapPath("/PageImages/" + pages.ImageName));
}
}
pages.PageSee = 0;
pages.CreateDate = DateTime.Now;
db.Pages.Add(pages);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(pages);
}