C1Editor撰写和管理HTML内容

ASP.NET Wijmo的C1Editor可以让非技术用户对任何网页上的HTML内容进行创作和管理。可以用这个直观的、像微软Word一样的编辑器来更换任何文本框,以及自定义风格。本文介绍了用C1Editor控件撰写和管理HTML内容。页面加载后,显示如下:<p><a href="http://www.grapecity.com.cn/image.ashx?picture=C1Editor.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="C1Editor" src="http://www.grapecity.com.cn/image.ashx?picture=C1Editor_thumb.png" alt="C1Editor" width="769" height="534" border="0" /></a></p>

发布于 2014/06/19 00:00

ComponentOne Enterprise

ASP.NET Wijmo的C1Editor可以让非技术用户对任何网页上的HTML内容进行创作和管理。可以用这个直观的、像微软Word一样的编辑器来更换任何文本框,以及自定义风格。

本文介绍了用C1Editor控件撰写和管理HTML内容。

添加C1Editor

添加C1Editor到页面,就生成了一个编辑器。该编辑器实现了微软办公软件Microsoft Office样式的功能区界面。此功能区可以将一些相关的命令组织到一系列的标签下,使得用户能够熟悉该编辑器的各项功能,而无需浏览菜单的层次结构。 参考代码:

<wijmo:C1Editor runat="server" 
ID="Editor1" Width="760" Height="530"  Text="The Insert tab contains groups of commands that enable end-users to insert items, 
such as images or paragraph breaks, into the text editor. 
Underneath the Format tab are four groups – Tables, Breaks, 
Forms, and Special – that house closely related tasks. " >
</wijmo:C1Editor>

C1Editor获取文件内容

添加txt数据源到App_Data文件夹。

通过File.OpenText打开现有的文本文件以进行读取。获取文件内容,参考代码如下:

private string GetFileContent()
{
    string text = string.Empty;
    StreamReader sr = File.OpenText(Server.MapPath("~/App_Data/JavaScript.txt"));
    try
    {
        text = sr.ReadToEnd();
    }
    catch { }
    finally
    {
        sr.Close();
     }
    return text;
 }

在页面加载的时候,将获取的文件内容设置给Editor.Text,将文件内容显示到C1Editor内。参考代码如下:

Editor1.Text = GetFileContent();

页面加载后,显示如下:

C1Editor

 

本文Demo的源代码如下:

C1Editor.7z (3.85 mb)

ComponentOne Enterprise | 下载试用

ComponentOne 是一套专注于企业 .NET开发、支持 .NET Core 平台,并完美集成于 Visual Studio 的第三方控件集,包含 300 多种 .NET开发控件,提供表格数据管理、数据可视化、报表和文档、日程安排、输入和编辑、导航和布局、系统提升工具等七大功能,被誉为“.NET开发的‘瑞士军刀’”。

ComponentOne 为您提供专业的产品咨询服务,并由技术支持工程师为您1对1解答。>> 发帖提问

相关产品
推荐相关案例
关注微信
葡萄城社区二维码

关注“葡萄城社区”

加微信获取技术资讯

加微信获取技术资讯

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态