THE START UP:-
This article shows you how to implement THE NEW CKEDITOR3.X within your webpage. Although its easier to show it in webpage but it becomes a bit messy when the matter comes to updating back the posted data. however, before proceeding I would suggest newbies to opt for ajax.net library, than to ckeditor.
First of all download the ckeditor, extract it ,double click the extracted folder,and thus copy the directory ckeditor (dont go beyond) to the project folder as shown in my examplecode.
THE PROGRAM:-
Paste following line into your head section of default.aspx
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
and your client is able to get access to these scripts..
Now
-
drag a textbox into your form tag & set its property to multiline textbox so it will change into textarea at client.
-
in the code behind file write:-
protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(cstype, Type cstype = this.GetType();"js2", "<script type=\"text/javascript\"> window.onload = function() {CKEDITOR.replace( '" textbox.ID+"' );};</script> ";
AND DONT FORGET TO ADD THIS TO HEAD SECTION
<script type="text/javascript">
window.onerror =function(){return true;}
</script>
YOU ARE READY TO USE YOUR CKEDITOR!!!!!!!!!!!!!!!!!!
copy the edit.aspx file (my code sample) this page shows all the files in your project (.htm or .aspx).
click anyone of the file & it will be brought inside the editor
insert this code into your page_load method (it loads to ckeditor):-
s = Request.QueryString["qr"];
if (!IsPostBack)
{
if (s != null)
{
fs = new FileStream(System.Configuration.ConfigurationManager.AppSettings["rd"].Trim() + s, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamReader sw = new StreamReader(fs);
String data = sw.ReadToEnd();
shot = data.Substring(0, data.IndexOf("<body>"));
editor1.Text = String.Format("{0}", data.Substring(data.IndexOf("<body>"), data.LastIndexOf("</body>") - data.IndexOf("<body>") - 1));
sw.Close();
fs = null;
}
}
-
Add a button to your form and its onclick event should have the following code:-
protected void Button1_Click(object sender, EventArgs e)
{
My.Visible = true;
if(s!=null)
{
fs = new FileStream(System.Configuration.ConfigurationManager.AppSettings["rd"].Trim() + s, FileMode.Truncate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter se = new StreamWriter(fs);
se.WriteLine(String.Format("{0} <body>{1}</body></html>", shot, editor1.Text));
se.Close();
My.InnerHtml = String.Format("<iframe id=\"polo\" width=\"1200\" src=\"{0}\"></iframe>", s);
}
}
-
lastly add following lines to your web.config
<appSettings>
<add key="C:\Users\Administrator\Documents\Visual Studio 2008\Projects\CK_editor\CK_editor\Web.configrd" value="C:\Users\Administrator\Documents\Visual Studio 2008\Projects\CK_editor\CK_editor\"/>
</appSettings>
CHEERS YOU R READY TO UPDATE YOUR PAGES!!!!!!!!!!!!!!!!!
IF SOURCE CODE IS NOT AVAILABLE AT CODE-PROJECT THEN DOWNLOAD IT FROM HERE:-