[英]Why would an ASP.NET page be empty, but for a user control (.ascx)?
I was hired to do some maintenance to a web site, and I found that there is a user control (.ascx) for every page (.aspx) and only one, like a one-to-one, and every .aspx is empty except for the user control. 我被雇用对网站进行一些维护,我发现每个页面(.aspx)都有一个用户控件(.ascx),只有一个,比如一对一,每个.aspx都是空的除了用户控件。 I dont see the use of that, because every user control is the entire page.
我没有看到使用它,因为每个用户控件都是整个页面。 Is there a benefit for doing that, or is it useless?
这样做有好处,还是没用? I'm afraid to say is something useless becouse I dont have much experience.
我不敢说是没用的因为我没有多少经验。
My site is built like this: I have several .ascx files and several .aspx files that contain just one user control. 我的网站是这样构建的:我有几个.ascx文件和几个只包含一个用户控件的.aspx文件。
Now there's also a special .aspx
file that's actually a single-page application on which I register every .ascx
control. 现在还有一个特殊的
.aspx
文件,它实际上是一个单页应用程序 ,我在其上注册每个.ascx
控件。 The reason I have .aspx
files for both the single-page application and for each separate "page" is that during development, I'm mostly working on one "page" at a time so I don't need to load all the other modules of the application. 我为单页应用程序和每个单独的“页面”提供
.aspx
文件的原因是,在开发期间,我主要是在一个“页面”上工作,所以我不需要加载所有其他应用程序的模块。 By keeping each module in a separate .ascx
file I can make changes to a module and the changes will seamlessly affect both the single-page version of the site as well as the .aspx
page I use for development purposes. 通过保持每个模块在一个单独
.ascx
文件,我可以改变一个模块和变化将无缝同时影响网站的单页版本,还有.aspx
我使用的开发目的页。
Hope this helps. 希望这可以帮助。
The UserControl is useful as it can be used in many places throughout the application. UserControl很有用,因为它可以在整个应用程序的许多地方使用。 If its only specific to one page, the user-control loses its purpose.
如果它仅针对一个页面,则用户控件将失去其目的。
User-Controls are supposed to be modular and supposed to be designed that they can easily be used in other pages. 用户控件应该是模块化的,并且应该设计为可以轻松地在其他页面中使用。
From the sounds of the application your maintaining, you'll have to see if the user control is unique to the page, or if its the same user control is used through the app and decide to move things. 根据您维护的应用程序的声音,您必须查看用户控件是否对页面是唯一的,或者是否通过应用程序使用相同的用户控件并决定移动内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.