Add a simple design

zhaozj2021-02-16  165

Using system; using system.web.ui; using system.Web.ui.webcontrols; using system.ComponentModel; use system.collections.specialize;

Namespace Wcl.MobileBox {///

/// Mobilebox's summary description. /// [DefaultProperty ("Text"), ToolboxData ("<{0}: MobileBox Runat = Server> "), Designer ("Wcl.MobileBox.MobileBoxDesigner), ] public class MobileBox: System.Web.UI.WebControls.WebControl, System.Web.UI.INamingContainer {string text; public string text {get {return text;} set {text = value;}} protected override void CreateChildControls () {TextBox m_TextBox1 = new TextBox (); m_TextBox1.Text = text; Controls.Add (m_TextBox1);} protected override void OnPreRender (EventArgs e) {Controls.Add (new LiteralControl ( "11111111111111111111111111111111"));}

Public Class MobileBoxDesigner: system.Web.ui.design.controlDesigner {public override string getdesigntimehtml () {MobileBox M_MobileBox = (MobileBox) Component;

TEXTBOX M_TEXTBOX = New TextBox (); StringWriter SW = New StringWriter (); HTMLTextWriter TW = New HTMLTextWriter (SW); M_TextBox.renderControl (TW); return sw.toString ();

}}}

Some questions: TextBox m_TextBox = new TextBox (); StringWriter sw = new StringWriter (); HtmlTextWriter tw = new HtmlTextWriter (sw); m_TextBox.RenderControl (tw); return sw.ToString (); modified StringWriter sw = new StringWriter ( HTMLTextWriter TW = New HTMLTextWriter (SW); M_MobileBox.renderControl (TW); return sw.toString (); not correct why Designer ("Wcl.MobileBox.MobileBoxDesigner), must be absolutely referenced?

转载请注明原文地址:https://www.9cbs.com/read-8744.html

New Post(0)