Chinaunix首页 | 论坛 | 博客
  • 博客访问: 39199
  • 博文数量: 26
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 275
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-20 20:38
个人简介

本人从事SEO

文章分类

全部博文(26)

文章存档

2015年(25)

2014年(1)

我的朋友

分类: 信息化

2015-04-02 11:06:13

1、首先在FCKeditor目录下的fckconfig.js文件,添加Readonly模式(可以将页面中的FCKeditor控件的ToolbarSets属性设置为“Readonly”,需要编辑时在代码中更改为“Default”):
FCKConfig.ToolbarSets["Readonly"] = [
['Preview','Print']
] ;
2、FCKeditor两种模式切换的函数:
private void ModFCKEditor(Boolean YN)
{
if (YN) //可编辑状态
{
string jsReadOnly = @"function FCKeditor_OnComplete( editor )
{
editor.EditorDocument.body.contentEditable = true;
editor.EditMode=FCK_EDITMODE_SOURCE;
editor.ToolbarSet.RefreshModeState();
editor.EditMode=FCK_EDITMODE_WYSIWYG;
editor.ToolbarSet.RefreshModeState();
}";
ClientScript.RegisterStartupScript(this.GetType(), "", "");
}
else //只读状态
{
string jsEnable = @"function FCKeditor_OnComplete( editor )
{
editor.EditorDocument.body.contentEditable = false;
editor.EditMode=FCK_EDITMODE_SOURCE;
editor.ToolbarSet.RefreshModeState();
editor.EditMode=FCK_EDITMODE_WYSIWYG;
editor.ToolbarSet.RefreshModeState();
}";
ClientScript.RegisterStartupScript(this.GetType(), "", "");
}
}
3、用ViewState控制FCKEditor的状态(记得在程序中控制状态,然后在需要的时候调用:this.ModFCKEditor(enableEditor);):
public Boolean enableEditor
{
get { return ViewState["enableEditor"] == null ? false : (Boolean)ViewState["enableEditor"]; }
set { ViewState["enableEditor"] = value; }
}
4、我的做法是将FCKeditor放在div里面,页面加载的时候该div是隐藏的,当点击查看的时候就显示div且FCKeditor为只读状 态,当点编辑按钮时将FCKeditor的ToolbarSets属性设置为“Default”,将enableEditor设置为True,再调用 this.ModFCKEditor(enableEditor)
5、数据显示我用的是GridView,控制列如下:









    <%# DataBinder.eval_r(Container.DataItem, "ID", "查看")%>
    







说明:查看功能转到的页面仍是当前页面,只不过此时带了参数!所以我用ViewState记录了FCKeditor的状态!
就这么多了,希望对大家有所帮助!

         文章信息来源        
阅读(462) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~