fck实现htm在线编辑
2016-07-19 20:16
507 查看
前端关键的fck初始化:var oFCKeditor = new FCKeditor("MyTextArea");
var sBasePath = "../../../../../Resource/theme/main_classic_standard/js/control/fckeditor/"
oFCKeditor.BasePath = sBasePath;
oFCKeditor.Height = "100%";
oFCKeditor.Width = "100%";
//页面全部元素加载完成后,再替换textArea
window.onload = function () {
oFCKeditor.ReplaceTextarea();
}
//FCKeditor控件加载完毕后,在调用FCKeditorAPI
function FCKeditor_OnComplete(oFCKeditor) {
var oEdotor = FCKeditorAPI.GetInstance("MyTextArea");
oEdotor.GetXHTML();
oEdotor.SetHTML($("#TexHtm").val());
}
后端加载初始化html内容,主要是讲初始化的html内容,加载到前端服务器隐藏控件中: /// <summary>
/// 显示数据
/// </summary>
/// <param name="Id"></param>
private void InitObjectInfo(string Id)
{
if (!string.IsNullOrEmpty(Id))
{
CheckTable entity = singleService.Get<CheckTable>(Id);
try
{
WebClient client = new WebClient();
string httpString = string.Empty;
httpString = client.DownloadString(Server.MapPath("~/Upfile/htm/" + entity.FileName));
TexHtm.Value = httpString;
}
catch
{
JSUtil.ShowAlert(this, "操作失败!");
return;
}
}
}
后端保存html事件:
private bool SaveRecord()
{
if (ValidatePage() == false) return false;//验证用户输入,用于输入合法性判断
if (ValidateInput() == false) return false;//验证用户输入,用于业务逻辑判断
if (ViewState["__EditMode"] == null) return false;
string strEditMode = ViewState["__EditMode"].ToString().ToLower();
try
{
if (strEditMode == "add")
{
CheckStandardItem entity = UIUtil.GenInstanceFromUI<CheckStandardItem>(this);
entity.CreateUser = GlobalUtil.CurrentUserAccount;
entity.ParentStandard = singleService.Get<CheckStandard>(sId.Value);
singleService.Save(entity);
UpFileModule1.UploadAttachments();//上传附件
}
}
catch
{
return false;
}
return true;
}
示例截图:
var sBasePath = "../../../../../Resource/theme/main_classic_standard/js/control/fckeditor/"
oFCKeditor.BasePath = sBasePath;
oFCKeditor.Height = "100%";
oFCKeditor.Width = "100%";
//页面全部元素加载完成后,再替换textArea
window.onload = function () {
oFCKeditor.ReplaceTextarea();
}
//FCKeditor控件加载完毕后,在调用FCKeditorAPI
function FCKeditor_OnComplete(oFCKeditor) {
var oEdotor = FCKeditorAPI.GetInstance("MyTextArea");
oEdotor.GetXHTML();
oEdotor.SetHTML($("#TexHtm").val());
}
后端加载初始化html内容,主要是讲初始化的html内容,加载到前端服务器隐藏控件中: /// <summary>
/// 显示数据
/// </summary>
/// <param name="Id"></param>
private void InitObjectInfo(string Id)
{
if (!string.IsNullOrEmpty(Id))
{
CheckTable entity = singleService.Get<CheckTable>(Id);
try
{
WebClient client = new WebClient();
string httpString = string.Empty;
httpString = client.DownloadString(Server.MapPath("~/Upfile/htm/" + entity.FileName));
TexHtm.Value = httpString;
}
catch
{
JSUtil.ShowAlert(this, "操作失败!");
return;
}
}
}
后端保存html事件:
private bool SaveRecord()
{
if (ValidatePage() == false) return false;//验证用户输入,用于输入合法性判断
if (ValidateInput() == false) return false;//验证用户输入,用于业务逻辑判断
if (ViewState["__EditMode"] == null) return false;
string strEditMode = ViewState["__EditMode"].ToString().ToLower();
try
{
if (strEditMode == "add")
{
CheckStandardItem entity = UIUtil.GenInstanceFromUI<CheckStandardItem>(this);
entity.CreateUser = GlobalUtil.CurrentUserAccount;
entity.ParentStandard = singleService.Get<CheckStandard>(sId.Value);
singleService.Save(entity);
UpFileModule1.UploadAttachments();//上传附件
}
}
catch
{
return false;
}
return true;
}
示例截图:
相关文章推荐
- c#调用COM组件
- C#实现把指定数据写入串口
- C#动态创建button的方法
- C#中抽象方法与虚拟方法的区别
- c#中虚函数的相关使用方法
- C#实现给图片加水印的方法
- C#使用加边法计算行列式的值
- C#实现多线程的同步方法实例分析
- C#中尾递归的使用、优化及编译器优化
- C#中的delegate委托类型基本学习教程
- C#实现子窗体与父窗体通信方法实例总结
- C#通用邮件发送类分享
- 举例讲解C#中自动实现的属性
- C#中this的用法集锦
- C#数据结构之顺序表(SeqList)实例详解
- C#.NET获取拨号连接的宽带连接方法
- C#异步绑定数据实现方法
- C#实现AddRange为数组添加多个元素的方法
- C#中Equality和Identity浅析
- C#比较二个数组并找出相同或不同元素的方法