Lightweight Rich Text Editor Control in ASP.NET MVC 2

There is a Lightweight Rich Text Editor Control on jQuery. I used this in a personal project in MVC, it made my otherwise clean pages messed up so I extented it to a control.

Following are the files which came in jQuery RTE plug-in

I added these script reference to master page

public static class TextEditorExtention
	public static string TextEditor(this HtmlHelper helper, string ID, string CssClass)
		string textArea = string.Format(@"
							<textarea id=""{0}"" name=""{0}"" class=""{1}""></textarea>",
														ID, CssClass);
		return string.Concat(@"<script type=""text/javascript"">
							$(document).ready(function () {
								var arr = $('.rte').rte({
									css: ['default.css'],
									controls_rte: rte_toolbar,
									controls_html: html_toolbar

									css: ['default.css'],
									width: 450,
									height: 200,
									controls_rte: rte_toolbar,
									controls_html: html_toolbar
								}, arr);
							</script>", textArea);

This is the code of helper class we write a method TextEditor as an extension method for HtmlHelper class

We use it as follows in aspx pages

<%= Html.TextEditor("txtContent","rte") %>

About Utkarsh Puranik

Software Engineer by Profession, Gamer by Nature, Techy by Attitude and a Good Person at Heart
This entry was posted in Technology and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s