如何在C#asp.net 4.0中使母版页模板成为模板 [英] How to make Master page templete in C# asp.net 4.0

查看:132
本文介绍了如何在C#asp.net 4.0中使母版页模板成为模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#asp.net 4.0中制作母版页模板
意味着单击按钮"后,将自动生成内容页面.

How to make Master page template in C# asp.net 4.0
means that when click Button then auto generate Content Page.

推荐答案

创建Maste页面在.NET 4.0中并没有真正改变.但是,这是有关如何创建它们的代码项目文章:

ASP.NET中初学者入门指南 [ ^ ]

根据您的更新,我会说取决于".如果要在运行时生成内容,则有多种方法可以执行此操作.最有效的方式以及大多数站点执行此操作的方式,是使用jQuery并在客户端上操作DOM.这是一个人这样做的例子:

http://www.moretechtips.net/2011/08/working- with-html-fragments-in-jquery.html [ ^ ]

如果要在服务器端操作页面(在GET或POST之后),则可以使用C#进行操作.基本上,您只需要根据信息调整控件即可.这是很常见的.实际上,这就是最初绘制大多数页面的方式.甚至ASP.NET中的内置模板在某种程度上也可以做到这一点.例如,您可以在显示页面之前用信息填写表格.同样,您可以在现有元素中添加标签或文本,也可以填充文本.

最后,如果您想在运行时创建物理页面(我建议您反对),则可以采用以下方法:

http://forums.asp.net/t/1306953.aspx/1 [ ^ ]

这些选项中的前两个很好,每个选项在您的页面中都有自己的位置.第三种选择是最后一种选择,除非您有非常具体的理由,否则不要使用.这三个都可以从一个模板开始,然后可以对其进行进一步的操作.它不是特殊的页面类型.只是一个常规页面,jQuery或C#会根据来自用户或情况的信息进行更改.
Creating Maste pages is something that hasn''t really changed that much in .NET 4.0. However, here is a Code Project article on how to create them:

Beginner''s Tutorial on Master Pages in ASP.NET[^]

Based upon your update, I would say "it depends". If you want to generate content at runtime, there are a number of ways to do this. The most efficient manner, and the way most sites do this, is by using jQuery and manipulating the DOM on the client side. Here is one example of a person doing just that:

http://www.moretechtips.net/2011/08/working-with-html-fragments-in-jquery.html[^]

If you wanted to manipulate the page on the server side (after a GET or POST), you could do that using C#. Basically you would just adjust the controls based upon the information. This is very common. In fact, it is how most pages are initially drawn. Even the built-in templates in ASP.NET do this to some extent. For example, you can fill in a table with information before displaying the page. In the same way, you could add labels or text or fill in text inside existing elements.

Finally, if you wanted to create physical pages at runtime (I would recommend against this), you could follow this method:

http://forums.asp.net/t/1306953.aspx/1[^]

The first two of these options are good and each has its place in your page. The third option is a last-resort and not to be used unless you have a very specific reason. All three could start with a template that could then be further manipulated. It wouldn''t be a special type of page. It would just be a regular page that either jQuery or C# changed based upon the information from the user or circumstance.


请看这里:
MSDN:ASP.NET母版页 [ ASPNET:ASP.NET母版页教程 [ ASP.NET 2.0主页 [将ASP.NET UpdatePanel控件与母版页一起使用 [此处 [
Look here:
MSDN: ASP.NET Master Pages[^]
ASPNET: ASP.NET Master Pages Tutorials[^]
ASP.NET 2.0 Master Pages[^]
Using the ASP.NET UpdatePanel Control with Master Pages[^]

If needed, look here[^] for more.


这篇关于如何在C#asp.net 4.0中使母版页模板成为模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆