Hello...I am using ckeditor in my mvc5 application...when i trying to modify data from "Edit View",it get the data from database but when i trying to save modified data it can not save..it give the error to save...plz help
piece of Edit view
@Html.LabelFor(model => model.Question1, "Question", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextAreaFor(model => model.Question1, new { @class = "ckeditor" })
@Html.ValidationMessageFor(model => model.Question1, "", new { @class = "text-danger" })
thank u
shervin salimianPosted Feb 8, 2018, 9:30 AM
Sanjay SabariyaPosted May 26, 2015, 2:05 AM
Sanjay SabariyaPosted May 26, 2015, 1:57 AM
PrakashPosted May 26, 2015, 1:40 AM
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
Question question = db.Questions.Find(id);
if (question == null)
{
return HttpNotFound();
}
ViewBag.Chapter = new SelectList(db.Chapters, "Id", "Name", question.Chapter);
return View(question);
}
// POST: Question/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "Id,Chapter,Question1,Answer_A,Answer_B,Answer_C,Answer_D,Answer_E,Explanation,Correct_Answer,Difficulty,Sequence")] Question question)
{
if (ModelState.IsValid)
{
db.Entry(question).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.Chapter = new SelectList(db.Chapters, "Id", "Name", question.Chapter);
return View(question);
}
view code
@model ExamAssist10.Question
@{
ViewBag.Title = "Edit";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.Id)
@Html.LabelFor(model => model.Sequence, "Sequence No.", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.Sequence, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Sequence, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Chapter, "Chapter Name", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.DropDownList("Chapter", null, htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Chapter, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Question1, "Question", htmlAttributes: new { @class = "control-label col-md-2" })
@* @Html.TextAreaFor(model => model.Question1, new { @class = "form-control" })*@
@*@Html.TextAreaFor(model => model.Question1, new { @class = "ckeditor" })*@
@Html.Raw(@Html.TextAreaFor(model => model.Question1, new { @class = "ckeditor" }))
@Html.ValidationMessageFor(model => model.Question1, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Answer_A, "Answer_A", htmlAttributes: new { @class = "control-label col-md-2" })
@* @Html.EditorFor(model => model.Answer_A, new { htmlAttributes = new { @class = "form-control" } }) *@
@Html.TextAreaFor(model => model.Answer_A, new { @class = "ckeditor" })
@Html.ValidationMessageFor(model => model.Answer_A, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Answer_B, "Answer_B", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextAreaFor(model => model.Answer_E, new { @class = "ckeditor" })
@Html.ValidationMessageFor(model => model.Answer_B, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Answer_C, "Answer_C", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextAreaFor(model => model.Answer_C, new { @class = "ckeditor" })
@Html.ValidationMessageFor(model => model.Answer_C, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Answer_D, "Answer_D", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextAreaFor(model => model.Answer_D, new { @class = "ckeditor" })
@Html.ValidationMessageFor(model => model.Answer_D, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Answer_E, "Answer_E", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextAreaFor(model => model.Answer_E, new { @class = "ckeditor" })
@Html.ValidationMessageFor(model => model.Answer_E, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Explanation, "Explanation", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.TextAreaFor(model => model.Explanation, new { @class = "ckeditor" })
@Html.ValidationMessageFor(model => model.Explanation, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Correct_Answer, "Correct_Answer", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.Correct_Answer, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Correct_Answer, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.Difficulty, "Difficulty", htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.Difficulty, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Difficulty, "", new { @class = "text-danger" })
}
@Html.ActionLink("Back to List", "Index")
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Sanjay SabariyaPosted May 26, 2015, 1:35 AM
PrakashPosted May 26, 2015, 1:14 AM
Exception: A potentially dangerous Request.Form value was detected from the client (Question1="
A coil havi
").Controller: Question
Action: Edit
Sanjay SabariyaPosted May 26, 2015, 1:02 AM