views:

46

answers:

1

Hi all I wanted to allow the users to enter html and links in textbox. How can I achieve something like this in ASP.NET MVC 2? I have something like this now...

<div class="editor-field">
                <%= Html.TextAreaFor(model => model.Description) %>
                <%= Html.ValidationMessageFor(model => model.Description) %>
 </div>

I found this link - http://stackoverflow.com/questions/2238393/allow-html-in-text-boxes-asp-net-mvc

But I am using ASP.NET MVC 2 and I am looking for something that MVC provides for this by default like a rich textbox or something and not just disable the validation.

+1  A: 

you could Encode the Value of the text area before posting the form(ClientSide), and then decode the value of the textarea when displaying the form(ServerSide). This would allow you to keep the validation there.

However it is good to mention that if you are using validation. What validator's are you using? Required, Length, some Custom Validator? I only mention this because if you are not using any actual validators on the field Description then maybe you do want to disable validation on that field. If you are using some Validators and you decide to encode on the client side and decode on the serverside then you need think about how the encoding will effect your validation code.

John Hartsock

related questions