ASP.NET @Register与@Reference [英] ASP.NET @Register vs. @Reference
问题描述
我和我的ASPX页面上引用的用户控件的工作,我想知道有什么区别这两个页面指令之间。
I'm working with referencing user controls on my ASPX page and I'm wondering what the difference is between these two page directives.
推荐答案
@Register
是较为常用的指令。当你想在你的ASPX或ASCX页面中使用用户控件声明可以使用此。 @Register
相关联与特定preFIX控制,然后你可以用它在你的标记。
@Register
is the more commonly used directive. You use this when you want to use a user control in your aspx or ascx page declaratively. @Register
associates the control with a specific prefix and you can then use it in your markup.
@Reference
只是告诉ASP.NET编译其他的控制,当你的aspx或ascx的编译页面。这确保它可在运行时,可以编程方式添加到您的控制层次。这是不常见的,因为动态变化的用户控件在运行时不COMON。
@Reference
only tells ASP.NET to compile the other control when your aspx or ascx page is compiled. That makes sure it is available at run-time and can be added to your control hierarchy programmatically. This is less common since dynamically changing user controls at runtime is not comon.
下面是一个很好的博客文章了。
Here's a good blog post about it.
的http://weblogs.asp.net/johnkatsiotis/archive/2008/08/13/the-reference-directive.aspx
这篇关于ASP.NET @Register与@Reference的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!