0

嗨,我希望能得到一些帮助。

我创建了一个具有一些基本功能的复合控件。我希望能够采用该复合控件并重用代码。

我该怎么做呢?我创建了一个类并从我的 cc 继承

public class PasswordTextBox : RoundedTextBox

现在,如果我向新的 cc 添加另一个属性,一切都结束了,但是页面上没有呈现任何内容。

我需要做哪些额外的步骤?

4

1 回答 1

0

你确定你调用了基类的渲染方法吗?您的 RoundedTextBox 是继承自 System.Web.UI.Control 还是 System.Web.UI.WebControls.WebControl?我假设它是从后者继承的,因为这就是 TextBox 的来源。

Protected virtual void RenderContents(HtmlTextWriter Writer)
{
      Base.Render(Writer);
}

看看这个链接,看看它是否有帮助: http ://www.aspfree.com/c/a/ASP.NET/ASPNET-Custom-Server-Controls-Breaking-the-Secrets-of-Rendering/3/

于 2010-07-08T05:43:29.170 回答