This question is locked. New answers and comments are not allowed.
Hi,
I am using telerik's Editor to accept formatted text from user in MVC3.
I am facing encoding and decoding related problem in that.
The code snippet is :
. View :
@(Html.Telerik().EditorFor(o => o.studentName).Encode(true)
.Tools(tools => tools.Clear().Bold().Italic().Underline().Separator().Strikethrough().FontName()
.FontSize(config => config.Add("inherited size", "8pt").Add("10 pixel", "10pt").Add("12 pixel", "12pt")
.Add("14 pixel", "14pt").Add("18 pixel", "18pt").Add("24 pixel", "24pt"))
.FontColor().BackColor().JustifyRight()
.JustifyCenter().JustifyLeft().JustifyFull().InsertOrderedList().InsertUnorderedList()
.Indent().Outdent().FormatBlock())
.HtmlAttributes(new { @class = "HTMLEditorWidget" })
Controller:
[HttpPost]
[ValidateInput(false)]
public ActionResult Index(StudentModel model)
{
if (some condition )
{
ModelState.ModelState.AddModelError(String.Empty,"There is Some Errror");
return View(model);
}
else
{
return RedirectToAction("Index", "Home");
}
}
Model:
class StudentModel
{
[AllowHtml]
[Display(Name = "CompanyProductName", ResourceType = typeof(PortalLocalization))]
[StringLength(50, "Student Name should not be greater than 50 charectors"]
public string StudentName{ get; set; }
}
The problem is when I try to save the data and if validation error Occurs the telerik editor shows me the text with HTML formatting( as shown in attached file).
I am using telerik's Editor to accept formatted text from user in MVC3.
I am facing encoding and decoding related problem in that.
The code snippet is :
. View :
@(Html.Telerik().EditorFor(o => o.studentName).Encode(true)
.Tools(tools => tools.Clear().Bold().Italic().Underline().Separator().Strikethrough().FontName()
.FontSize(config => config.Add("inherited size", "8pt").Add("10 pixel", "10pt").Add("12 pixel", "12pt")
.Add("14 pixel", "14pt").Add("18 pixel", "18pt").Add("24 pixel", "24pt"))
.FontColor().BackColor().JustifyRight()
.JustifyCenter().JustifyLeft().JustifyFull().InsertOrderedList().InsertUnorderedList()
.Indent().Outdent().FormatBlock())
.HtmlAttributes(new { @class = "HTMLEditorWidget" })
Controller:
[HttpPost]
[ValidateInput(false)]
public ActionResult Index(StudentModel model)
{
if (some condition )
{
ModelState.ModelState.AddModelError(String.Empty,"There is Some Errror");
return View(model);
}
else
{
return RedirectToAction("Index", "Home");
}
}
Model:
class StudentModel
{
[AllowHtml]
[Display(Name = "CompanyProductName", ResourceType = typeof(PortalLocalization))]
[StringLength(50, "Student Name should not be greater than 50 charectors"]
public string StudentName{ get; set; }
}
The problem is when I try to save the data and if validation error Occurs the telerik editor shows me the text with HTML formatting( as shown in attached file).