- Upload Images and integrate with CKEditor in ASP.NET
- Calling a WebService using jQuery in ASP.Net
ckeditor_4.5.6_standard.zip
ckeditor_4.5.6_83e545c0edb5.zip
write.aspx
<%@ Page Language="C#" ValidateRequest="false" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CKEditor_test.WebForm1" %>
<!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 type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div >
<table><tr><td width="600px" height="300px">
<asp:TextBox ID="TextBox1" runat="server" " TextMode="MultiLine" ></asp:TextBox>
<script type="text/javascript">
//<![CDATA[
CKEDITOR.replace('TextBox1',
{
toolbar: 'Full',
uiColor: '#9AB8F3',
filebrowserUploadUrl: '/upload.ashx?type=Files',
filebrowserImageUploadUrl: '/upload.ashx?type=Images',
filebrowserFlashUploadUrl: '/upload.ashx?type=Flash'
}
);
//]]>
</script>
</td></tr></table>
</div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
upload.ashx
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace CKEditor_test
{
public class upload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpPostedFile uploads = context.Request.Files["upload"];
string CKEditorFuncNum = context.Request["CKEditorFuncNum"];
string file = System.IO.Path.GetFileName(uploads.FileName);
uploads.SaveAs(context.Server.MapPath(".") + "\\Images\\" + file);
string url = "/Images/" + file;
context.Response.Write("<script>window.parent.CKEDITOR.tools.callFunction(" + CKEditorFuncNum + ", \"" + url + "\");</script>");
context.Response.End();
}
public bool IsReusable {
get {
return false;
}
}
}
}