开发者

Extending a WebControl using a partial class

Is is possible to extend, for instance, the HyperLink control using a partial class?

I'd like to define some custom properties on the control, without having to extend the class... like so...

<asp:HyperLink runat="server"开发者_JAVA百科 CustomPropertyA="a" CustomPropertyB="b" />

And be able to use them on OnInit/OnPreload etc.


No. Partial types only allow you to specify the code for a type within multiple source files within the same project. That's all. They're a compile-time change only - they don't affect the object model, or what you can do with types which already exist etc.

It sounds like you may just want to create a new class derived from HyperLink instead.


As Jon said, you have to create a new class derived from HyperLink. But if you are after to keep the old tag structure, use tag mapping as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜