Abhay Andhariya
Abhay Andhariya

Reputation: 2157

How to make HTML Tags possible to accept in Textarea in mvc Razor?? Or which other controls should i use to do that?

Hello guys,

I have created one textarea in my application.

And now i want to add HTML tags in my textarea and want to accept it using following tag

  @Html.TextBoxFor(model => model.PageTitle, new { style = "Width:500px; maxlength=500;" })

It doesn't allow HTML code but the simple text. So what should i do for that???

Upvotes: 0

Views: 1954

Answers (2)

Dmitry Efimenko
Dmitry Efimenko

Reputation: 11203

apply the following attribute to the property PageTitle:

[AllowHtml]
public string PageTitle { get; set; }

Upvotes: 3

Brad Christie
Brad Christie

Reputation: 101614

Two options:

  1. Create a custom EditorTemplate, but that involves also
  2. Use @Html.TextBox which does have the overload to use custom HTML attributes.

This is assuming you meant attributes and not tags as your example code implies.

Upvotes: 0

Related Questions