- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Testing123.aspx.cs" Inherits="Testing123" ValidateRequest="false" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <%@ Register Assembly="FreeTextBox" Namespace="FreeTextBoxControls" TagPrefix="FTB" %>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head id="Head1" runat="server">
- <title>Richtextbox Sample</title>
- <script type="text/javascript">
- function validate()
- {
- var doc = document.getElementById(
- 'FreeTextBox1');
- if (doc.value.length == 0)
- {
- alert(
- 'Please Enter data in Richtextbox');
- return false;
- }
- }
- </script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <table>
- <tr>
- <td>
- <FTB:FreeTextBox ID="FreeTextBox1" runat="server">
- </FTB:FreeTextBox>
- </td>
- <td valign="top">
- <asp:GridView runat="server" ID="gvdetails"
- AutoGenerateColumns="false">
- <Columns>
- <asp:TemplateField HeaderText="RichtextBoxData">
- <ItemTemplate>
- <asp:Label ID="lbltxt" runat="server" Text='<%#Bind("RichtextData") %>'
- />
- </ItemTemplate>
- </asp:TemplateField>
- </Columns>
- </asp:GridView>
- </td>
- </tr>
- </table>
- </div>
- <asp:Button ID="btnSubmit" runat="server"
- OnClientClick="return validate()" Text="Submit"
- onclick="btnSubmit_Click" /><br />
- <asp:Label ID="lbltxt" runat="server" />
- </form>
- </body>
- </html>
In Web.Config File
- <system.web>
- <httpRuntime requestValidationMode="2.0"
- />
- <pages validateRequest="false">
- </pages>
- </system.web>
In Code File
- using System;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.SqlClient;
- public partial class Testing123: System.Web.UI.Page
- {
- SqlConnection _SqlCon = new SqlConnection();
- SqlCommand _SqlCmd = new SqlCommand();
- DataSet ds = new DataSet();
- Notification objNoti = new Notification();
- protected void Page_Load(object sender,
- EventArgs e)
- {
- _SqlCon.ConnectionString =
- DBConnect.GetConnectiion();
- _SqlCmd.Connection = _SqlCon;
- if (!IsPostBack)
- {
- BindGridview();
- }
- }
- protected void BindGridview()
- {
- ds = objNoti.Get_RichTextData(
- FreeTextBox1.Text);
- if (ds.Tables[0].Rows.Count > 0)
- {
- gvdetails.DataSource = ds;
- gvdetails.DataBind();
- }
- }
- protected void btnSubmit_Click(object sender,
- EventArgs e)
- {
- objNoti.Insert_RichText(
- FreeTextBox1.Text);
- BindGridview();
- }
- }
Database Structure
Coloumn Name Datatype AllowNulls
id Int No
RichTextData nvarchar(MAX) Yes