主题: 如何将4.1的封装成NET控件? |
作者: abis, 发布日期: 2012-09-10 15:17:52, 浏览数: 3382 |
3.5.1的已经搞好,如下代码 <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Editor.ascx.cs" Inherits="Abis.Web.Resources.Ascx.Editor" %> <script type="text/javascript" charset="utf-8" src="/Resources/Ascx/Editor/kindeditor.js"></script> <script type="text/javascript"> var txtInfoContextId = '<%=TxtContent.ClientID%>'; //这里获得客户端ID KE.show({ id: txtInfoContextId, imageUploadJson: '/Resources/Ascx/Editor/upload_json.ashx' }); </script> <asp:TextBox ID="TxtContent" runat="server" TextMode="MultiLine" Height="400px" Width="700px"></asp:TextBox> using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Abis.Web.Resources.Ascx { public partial class Editor : System.Web.UI.UserControl { //private string Content = ""; protected void Page_Load(object sender, EventArgs e) { //this.TxtContent.Text = Content; } public string Text { set { TxtContent.Text = value; } get { return TxtContent.Text; } } public bool Enabled { set { this.TxtContent.Enabled = value; } get { return this.TxtContent.Enabled; } } } } 我在搞4.1的时候,发现不显示,以下是我写的相关代码,请帮忙看看! <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="KindEditor.ascx.cs" Inherits="Abis.Web.Resources.Ascx.KindEditor" %> <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> <link rel="stylesheet" href="/Resources/Ascx/KindEditor/themes/default/default.css" /> <link rel="stylesheet" href="/Resources/Ascx/KindEditor/plugins/code/prettify.css" /> <script type="text/javascript" language="javascript" charset="utf-8" src="/Resources/Ascx/KindEditor/kindeditor.js"></script> <script type="text/javascript" language="javascript" charset="utf-8" src="/Resources/Ascx/KindEditor/lang/zh_CN.js"></script> <script type="text/javascript" language="javascript" charset="utf-8" src="/Resources/Ascx/KindEditor/plugins/code/prettify.js"></script> <script type="text/javascript" language="javascript"> KindEditor.ready(function (K) { var editor = K.create('#TxtContent', { cssPath: '/Resources/Ascx/KindEditor/plugins/code/prettify.css', uploadJson: '/Resources/Ascx/KindEditor/Server/upload_json.ashx', fileManagerJson: '/Resources/Ascx/KindEditor/Server/file_manager_json.ashx', allowFileManager: true, //编辑器高度 width: '680px', //编辑器宽度 height: '300px;' }); prettyPrint(); }); </script> <asp:TextBox ID="TxtContent" runat="server" TextMode="MultiLine"></asp:TextBox> using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Abis.Web.Resources.Ascx { public partial class KindEditor : System.Web.UI.UserControl { //private string Content = ""; protected void Page_Load(object sender, EventArgs e) { //this.TxtContent.Text = Content; } public string Text { set { TxtContent.Text = value; } get { return TxtContent.Text; } } public bool Enabled { set { this.TxtContent.Enabled = value; } get { return this.TxtContent.Enabled; } } } } |
作者: Roddy, 发布日期: 2012-09-10 18:03:50 |
ID不对呀,应该这样写。
var txtInfoContextId = '<%=TxtContent.ClientID%>'; //这里获得客户端ID| .... var editor = K.create('#' + txtInfoContextId, .......
|
回复 |
作者: abis, 发布日期: 2012-09-10 22:14:53 |
成功,非常感谢!!!!
|
回复 |