富文本框tinyeditor的用法

转载 : https://blog.csdn.net/xyy410874116/article/details/54924164

一、导入   tinyeditor的类和js包,具体tinyeditor包在我的资源里面有的,网上也有很多资源,自己下载,此处不做多介绍

<link rel="stylesheet" href="../tinyeditor/style.css" />

<script type="text/javascript" src="../tinyeditor/tinyeditor.js"></script>

二、添加textarea控件

 <textarea id="input"  style="width:400px; height:200px"></textarea>
<script type="text/javascript">
    var instance = new TINY.editor.edit('editor', {
        id: 'input',
        width: 584,
        height: 175,
        cssclass: 'te',
        controlclass: 'tecontrol',
        rowclass: 'teheader',
        dividerclass: 'tedivider',
        controls: ['bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|',
 'orderedlist', 'unorderedlist', '|', 'outdent', 'indent', '|', 'leftalign',
 'centeralign', 'rightalign', 'blockjustify', '|', 'unformat', '|', 'undo', 'redo', 'n',
 'font', 'size', 'style', '|', 'image', 'hr', 'link', 'unlink', '|', 'cut', 'copy', 'paste', 'print'],
        footer: true,
        fonts: ['新宋体', '黑体', 'Verdana', 'Arial', 'Georgia', 'Trebuchet MS', '微软雅黑', '宋体', '幼圆', '楷体', '华文行楷'],
        xhtml: true,
        cssfile: 'style.css',
        bodyid: 'editor',
        footerclass: 'tefooter',
        toggle: { text: 'source', activetext: 'wysiwyg', cssclass: 'toggle' },
        resize: { cssclass: 'resize' }
    });

三、点击按钮获得文本框的输入值

1、前端获得值方法:

<asp:Button ID="Button1" runat="server" Text="提交" OnClientClick="checkform()"  />

function checkform() {
        instance.post();
        var txtContent = document.getElementById("input").value; 
       
    }

2、后台获得值方法:

添加隐藏按钮<asp:HiddenField ID="txthidden" runat="server"/>

function checkform() {
        instance.post();
        var txtContent = document.getElementById("input").value;
        document.getElementById('txthidden').value = txtContent;
       
    }

 <asp:Button ID="Button1" runat="server" Text="提交"  OnClick="Button1_Click" />

在后台直接读取txthidden的值即可


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值