简体   繁体   English

asp.net 2.0表单-共享/公用HTML

[英]asp.net 2.0 Forms - Shared/Common HTML

I have the need to expand an asp.net 2.0 web application that I recently created. 我需要扩展最近创建的asp.net 2.0 Web应用程序。 Currently there is a single page that contains some embedded HTML that is needed in a separate section of the application in a new page that I am working on. 当前,只有一个页面包含一些嵌入的HTML,这是我正在处理的新页面中应用程序的单独部分所需的。 On this new page, I am going to be using the HTML multiple times throughout the page, mostly duplicating the HTML with JavaScript/jQuery. 在这个新页面上,我将在整个页面中多次使用HTML,主要是使用JavaScript / jQuery复制HTML。 So I am not sure if I want to have the HTML in a JavaScript variable or hidden in the page and then call $.clone() on the HTML to dynamically recreate it. 因此,我不确定是否要在JavaScript变量中隐藏HTML或将HTML隐藏在页面中,然后在HTML上调用$.clone()来动态地重新创建它。

Is there a way to have shared HTML files within an asp.net 2.0 forms web application so that I do not have to complete dual maintenance of code; 有没有一种方法可以在asp.net 2.0 表单 Web应用程序中共享HTML文件,这样我就不必完成代码的双重维护。 I assume similar to the way that an MVC application would work (although I am not completely familiar with how MVC HTML works). 我假设它类似于MVC应用程序的工作方式(尽管我并不完全了解MVC HTML的工作方式)。

Create it as a User Control if it's only ever going to be deployed within a single project - otherwise you would have some duplication of effort with versioning. 如果仅将其部署在单个项目中,则将其创建为用户控件-否则,您在版本控制方面会有些重复。 If that's the case, re-create it as a server control and emit the HTML/JS from there; 如果是这种情况,请重新将其创建为服务器控件,然后从那里发出HTML / JS; server controls can be shared across projects from their own library. 服务器控件可以从其自己的库跨项目共享。 You'll only need to maintain one copy. 您只需要维护一份副本。

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

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