简体   繁体   English

为什么ASP.NET页面为空,但对于用户控件(.ascx)?

[英]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.

相关问题 注册ASP.NET页面或母版页中的.ascx ASP.NET用户控件是否会加载? - Registering .ascx ASP.NET User control in ASP.NET Page or Master Page will load it or not? 在asp.net mvc布局页面上使用用户控件(.ascx)时出错 - Getting Error in using user control(.ascx) on asp.net mvc layout page 从 ASP.Net 中的 ascx 页面获取控件 - Grabbing a control from an ascx page in ASP.Net 如何生成PDF并加载ASCX asp.net用户控件的内容? - How can I generate a PDF and load the contents of an ASCX asp.net user control? ASP.NET-如何将Web用户控件(.ascx)打包到DLL中以供其他应用程序使用? - ASP.NET - How do I package a Web User Control (.ascx) in a DLL for use in other applications? 将数据从ASP.NET页面传递到动态加载的ASCX用户控件 - Pass data from a ASP.NET page to ASCX user controls loaded dynamically 如何在ascx控件的asp.net中添加表单和类标记 - How to add form and class tag in asp.net in ascx control ASP.NET:获取对父ASCX控件的强类型引用 - ASP.NET: Get a strongly typed reference to a parent ASCX control 如何从客户端.ascx使用控件ID并在服务器端ascx.cs(ASP.NET)中使用它 - How to use control ID from clientside .ascx and use it in serverside ascx.cs (ASP.NET) asp.net-ascx和页面之间的可变传递 - asp.net - variable pass between ascx and page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM