简体   繁体   English

在网站项目中扩展asp.net控件

[英]extending asp.net control in the website project

when I extend an asp.net control and place the extended control class in, say, Applicaton_code 当我扩展一个asp.net控件并将扩展控件类放在,例如,Applicaton_code
(without specifying the namespace) how do i register the control to use it on a webpage? (不指定命名空间)如何注册控件以在网页上使用它?
what assembly name and namespace should be specified? 应该指定什么程序集名称和命名空间?

use : 采用 :

<%@Register TagPrefix="local" Assembly="App_Code" Namespace="Controls" %>

Also, you HAVE to defines a namespace where to put your controls (from memory, when adding class to App_code, no namespace is generated by default). 此外,你必须定义一个命名空间在哪里把你的控制(从内存中,添加类的app_code时,默认情况下不会产生命名空间)。

namespace Controls {
    public class control1 : WebControl {
    }

}

and then , in the aspx file 然后,在aspx文件中

<local:control1 runat="server", id="youreluckyitworks" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM