一、導入 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', ' 三、點擊按鈕獲得文本框的輸入值 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的值即可
新聞熱點
疑難解答