with the help of ajax htmleditor extender we can send messages like office word with different styles.. as shown below...
here i am using database to store the text in the htmlextender.
create a database htmlextender
as
create database htmlextender
now create a table named as data
as
create table data
(
data varachar(Max)
)
the aspx code looks like this
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>ReddyInfoSoft.blogspot.in</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="300" Width="700"></asp:TextBox>
<asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="TextBox1">
</asp:HtmlEditorExtender>
</div>
<asp:Button ID="btnOk" runat="server" Text="Submit" onclick="btnOk_Click" />
<asp:Button ID="btnRetrive" runat="server" Text="Retrive"
onclick="btnRetrive_Click"/>
<asp:Button ID="btnRetrive1" runat="server" Text="Retrive"
onclick="btnRetrive1_Click" />
<br />
<asp:Label ID="lblShow" runat="server"></asp:Label>
<br />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</body>
</html>
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlDataAdapter da;
string strCon = "database=htmlextender; uid=sa; pwd=****; data source=(local)\\****;";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOk_Click(object sender, EventArgs e)
{
lblShow.Text = TextBox1.Text.ToString();
SqlConnection con = new SqlConnection(strCon);
DataSet ds = new DataSet();
da = new SqlDataAdapter("insert into data (data) values ('" + TextBox1.Text.ToString() + "')", con);
da.Fill(ds,"data1");
}
protected void btnRetrive_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strCon);
DataSet ds = new DataSet();
da = new SqlDataAdapter("select top 1 data from data order by data", con);
da.Fill(ds, "data2");
TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();
}
protected void btnRetrive1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strCon);
DataSet ds = new DataSet();
da = new SqlDataAdapter("select * from data order by data", con);
da.Fill(ds, "data1");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
here i am using database to store the text in the htmlextender.
create a database htmlextender
as
create database htmlextender
now create a table named as data
as
create table data
(
data varachar(Max)
)
the aspx code looks like this
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>ReddyInfoSoft.blogspot.in</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Height="300" Width="700"></asp:TextBox>
<asp:HtmlEditorExtender ID="HtmlEditorExtender1" runat="server" TargetControlID="TextBox1">
</asp:HtmlEditorExtender>
</div>
<asp:Button ID="btnOk" runat="server" Text="Submit" onclick="btnOk_Click" />
<asp:Button ID="btnRetrive" runat="server" Text="Retrive"
onclick="btnRetrive_Click"/>
<asp:Button ID="btnRetrive1" runat="server" Text="Retrive"
onclick="btnRetrive1_Click" />
<br />
<asp:Label ID="lblShow" runat="server"></asp:Label>
<br />
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</form>
</body>
</html>
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
SqlDataAdapter da;
string strCon = "database=htmlextender; uid=sa; pwd=****; data source=(local)\\****;";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOk_Click(object sender, EventArgs e)
{
lblShow.Text = TextBox1.Text.ToString();
SqlConnection con = new SqlConnection(strCon);
DataSet ds = new DataSet();
da = new SqlDataAdapter("insert into data (data) values ('" + TextBox1.Text.ToString() + "')", con);
da.Fill(ds,"data1");
}
protected void btnRetrive_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strCon);
DataSet ds = new DataSet();
da = new SqlDataAdapter("select top 1 data from data order by data", con);
da.Fill(ds, "data2");
TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();
}
protected void btnRetrive1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strCon);
DataSet ds = new DataSet();
da = new SqlDataAdapter("select * from data order by data", con);
da.Fill(ds, "data1");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
No comments:
Post a Comment