.net中页面插入CKEditor编辑器
首先是配置,下载好。
然后把里面的文件夹放进web根目录下。
ok,现在就可以了
前台代码如下:
[html]
<head runat="server">
<title></title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<form id="form1" method="post" runat="server">
<div style="width:500px;height:300px;">
<asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" CssClass="ckeditor"></asp:TextBox>
<asp:Button runat="server" Text="保存" ID="btn_OK" onclick="btn_OK_Click"/>
</div>
</form>
</body>
<head runat="server">
<title></title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>
<body>
<form id="form1" method="post" runat="server">
<div style="width:500px;height:300px;">
<asp:TextBox ID="txtContent" runat="server" TextMode="MultiLine" CssClass="ckeditor"></asp:TextBox>
<asp:Button runat="server" Text="保存" ID="btn_OK" onclick="btn_OK_Click"/>
</div>
</form>
</body>
后台代码只是简单的获取到TextBox里的内容就可以了,下面包含我测试用的把数据写进一个txt格式的文本里
[csharp]
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strPath = "E:\\jin\\CompanyProject\\WebSite\\Web\\txt\\txt.Txt";
//读取:
txtContent.Text = File.ReadAllText(strPath);
}
}
protected void btn_OK_Click(object sender, EventArgs e)
{
string Data = txtContent.Text;
//string st = Request.Form.Set[form1].tostring();
string Data2 = Request.Form[txtContent.Text.ToString()];
string strContent = Data;
string strPath = "E:\\jin\\CompanyProject\\WebSite\\Web\\txt\\txt.Txt";//如: D:/Text/File.Txt
File.WriteAllText(strPath, strContent);//保存文件
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string strPath = "E:\\jin\\CompanyProject\\WebSite\\Web\\txt\\txt.Txt";
//读取:
txtContent.Text = File.ReadAllText(strPath);
}
}
protected void btn_OK_Click(object sender, EventArgs e)
{
string Data = txtContent.Text;
//string st = Request.Form.Set[form1].tostring();
string Data2 = Request.Form[txtContent.Text.ToString()];
string strContent = Data;
string strPath = "E:\\jin\\CompanyProject\\WebSite\\Web\\txt\\txt.Txt";//如: D:/Text/File.Txt
File.WriteAllText(strPath, strContent);//保存文件
}
效果如下:
补充:Web开发 , ASP.Net ,