XhEditor supports code insertion, and xheditor inserts code
If you often use CSDN or other technical blogs, you will have the function of inserting program code or scripts.
Open source China
CSDN
This section describes how to implement the Code insertion function of xhEditor and extension of xhEditor.
I. first define the plug-in style
<Style type = "text/css">/* Add the insert Code tool icon */. btnCode {background: transparent url (img/code.png) no-repeat 0px 0px; background-position: 3px-2px ;}</style>
2. Define the plug-in. First, determine the plug-in name (INS) and then define the relevant parameters (For details, refer to the xheditor api documentation). The Code is roughly as follows:
Define the javascript code of the plug-in
<Script type = "text/javascript"> $ (function () {var plugins = {Code: {c: 'btncode', t: 'insert Code', h: 1, e: function () {var _ this = this; var htmlCode = "<div> programming language <select id = 'xhecodetype '> "; htmlCode + = "<option value = 'html'> html/XML </option>"; htmlCode + = "<option value = 'js'> Javascript </option> "; htmlCode + = "<option value = 'css '> css </option>"; htmlCode + = "<option value = 'php'> php </option> "; htmlCode + = "<option value = 'java'> java </option>"; htmlCode + = "<option value = 'py'> Python </option> "; htmlCode + = "<option value = 'pl '> Perl </option>"; htmlCode + = "<option value = 'rb'> Ruby </option> "; htmlCode + = "<option value = 'cs '> C # </option> "; htmlCode + = "<option value = 'C'> c ++/C </option> "; htmlCode + = "<option value = 'vb '> vb/ASP </option>"; htmlCode + = "<option value =''> others </option> "; htmlCode + = "</select> </div> <div> "; htmlCode + = "<textarea id = 'xhecodevalue' wrap = 'soft' spellcheck = 'false' style = 'width: 300px; height: 100px; '/> "; htmlCode + = "</div> <div style = 'text-align: right; '> <input type = 'button' id = 'xhesave 'value = 'true'/> </div> "; var jCode = $ (htmlCode ), jType = $ ('# xheCodeType', jCode), jValue = $ ('# xhecodevalue', jCode), jSave = $ (' # xheSave ', jCode); jSave. click (function () {_ this. loadBookmark (); _ this. pasteHTML ('<pre class = "brush:' + jType. val () + '">' + _ this. domEncode (jValue. val () + '</pre>'); _ this. hidePanel (); return false ;}); _ this. saveBookmark (); _ this. showDialog (jCode) ;}},}; $ ('# content '). xheditor ({plugins: plugins, // use our defined plugin loadCSS: '<style> pre {margin-left: 2em; border-left: 3px solid # CCC; padding: 0 1em ;}</style> ',}) ;}) </script>
3. OK:
The effect is the same as that of CSDN, because CSDN uses xhEditor.
Project demo source code download: http://download.csdn.net/detail/itmyhome/7750927
Reprinted please indicate the source: http://blog.csdn.net/itmyhome1990/article/details/38495623
C # net three-tier architecture for code insertion
Write the Dal layer first
Public datatable GetTable ()
{
SqlConnection conn = new SqlConnection ();
Conn. ConnectionString = "Server = (local); database = db; uid = sa; pwd = sa"; // connect to the data source
Conn. Open ();
String strsql = "insert into table values ()";
SqlCommand cmd = new SqlCommand (strsql, conn );
Try
{
Cmd. ExecuteNonQuery ();
Return true;
}
Catch (SqlException)
{
Return false;
}
Finally
{
Conn. Close ();
}
Bll Layer
// Instantiate the Dal Layer Method
DAL dal = new DAL ();
Public bool BllGetTable ()
{// Obtain the data table
Return dal. GetTable ();
}
Page Layer
// Instantiate the Bll Layer Method
Bll bll = new Bll ();
// Call The Bll Layer Method
Bool insert = bll. BllGetTable ();
How can I display the emoticon Uploaded By xhEditor on the next page?
Webpage graphic editor [xhEditor], which can upload files and add emojis... xhEditor is based on jQuery... optimize the Word automatic document clearing function, step 1 to improve code processing efficiency, and be compatible with Excel document pasting optimization: optimized. view Original post>