using System;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Collections.Specialized;
namespace WCL.MobileBox
{
/// <summary>
/// MobileBox 的摘要说明。
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:MobileBox runat=server></{0}:MobileBox>"),
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();
}
}
}
一些问题:
TextBox m_TextBox=new TextBox();
StringWriter sw = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);
m_TextBox.RenderControl(tw);
return sw.ToString();
修改成
StringWriter sw = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);
m_MobileBox.RenderControl(tw);
return sw.ToString();
就不正确了 为什么
Designer("WCL.MobileBox.MobileBoxDesigner"), 必须用绝对引用么