Generic ServerControl syntax?

核能气质少年 提交于 2019-12-10 15:22:32

问题


Is there a way that I can have a server control

MyControl<T>

so that I can register and use it in an aspx page like so

<mc:MyControl<ThingForControlToUse> ID="instanceOfMyControl" runat="server"

Obviously the designer doesn't like this, are there any cool ways round it other than creating a non generic wrapper with a type parameter?


回答1:


Generic Tag Names are not possible in ASP.NET, please refer to this article: Generic Controls

You are on the right track in thinking that you will need to create a wrapper with a TYPE parameter.




回答2:


A quick note - I am not sure if this is true in Visual Studio 2008 but if you were to have that control in a project that you were editing with Visual Studio 2005 you would completely break intellisense with that control. When Visual Studio attempts to create XML schema files to use for intellisense popups in markup files it completely breaks when it sees generic controls like this one and it abandons the schema file completely leaving you with no intellisense for any controls in that assembly.



来源:https://stackoverflow.com/questions/863270/generic-servercontrol-syntax

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!