Introduction
This article will help you to create a HTML editor in ASP.NET web pages using jQuery. If your are using the AJAX HTML Editor Extender then that means it will take more time to load the AJAX toolkit. The jQuery editor is an easy and lightweight HTML editor for ASP.NET pages.
Step 1
Open Visual Studio then click on Add New Project then add a webform (default.aspx).
Step 2
Add the following script in your head tag. I have attached the source file with the necessary CSS and scripts files. Please find it and call those files.
- <script src=jquery-1.3.2.js" type="text/javascript"></script>
-
- <script src="Html_editor/scripts/jHtmlArea-0.8.min.js" type="text/javascript"></script>
- <link href="Html_editor/scripts/jHtmlArea.css" rel="stylesheet" type="text/css" />
-
- <script type="text/javascript">
- $(function () {
- $("textarea").htmlarea();
- });
- </script>
Step 3
Add the following text area within your form tag.
- <textarea runat="server" id="txtText" cols="50" rows="15"></textarea>
Output
Full Example (C#)
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendEmail.aspx.cs" Inherits="AdventureSports.Public.SendEmail" %>
-
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <script src="../HTML_Editor/scripts/jquery-1.3.2.js" type="text/javascript"></script>
-
- <script src="../HTML_Editor/scripts/jHtmlArea-0.8.min.js" type="text/javascript"></script>
- <link href="../HTML_Editor/style/jHtmlArea.css" rel="stylesheet" type="text/css" />
-
- <script type="text/javascript">
- $(function () {
- $("textarea").htmlarea();
-
-
- });
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <textarea runat="server" id="txtText" cols="50" rows="15"></textarea>
- </div>
- </form>
- </body>
- </html>
This is the procedure to implement a lightweight HTML editor in your web pages in a simple manner.
Thank you!