且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是.ascx控件?以及如何在C#中使用此控件?

更新时间:2023-02-08 15:11:06

ASP.NET使您能够创建用户定义的自定义控件,这些控件在可重用性方面非常有用.开发用户控件后,您会觉得它似乎是由asp.net提供的普通控件.

ASP.NET provides you the ability to create user defined custom controls that are very useful in terms of re-usability. Once you develop a user control, you will feel that it seems like a normal control that are provided by asp.net.

用户控件就像扩展名为.ascx的asp.net页面.您像普通页面一样在后面有标记和代码.您可以在用户控件内放置任何有效的HTML和asp.net内置控件,并使用它们.

A user control is like an asp.net page with .ascx extension. You have markup and code behind like a normal page. You can put any valid HTML and asp.net build in controls inside the user controls and use it.

完成控件构造后,您需要在网站上注册控件以使用它.您可以按页面注册,也可以在web.config文件中注册并在完整的网站中使用.

Once you are done with control construction, you need to register the control to use it on your website. You can register in on page basis or you can register in web.config file and use it in complete website.

在Google或SO上进行一些搜索,将为您提供有关用户控件使用方式的更多详细信息.

A little search on Google or on SO will provide you more details on the usage of user controls.

希望这种理论将对您有所帮助,并提供一些对用户控制的理解.

Hope this theory will help you and provide some understanding of user control.