在c#中动态创建html页面? [英] dynamically create html page in c#?

查看:368
本文介绍了在c#中动态创建html页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。我是动态创建html的新手。我的要求是,我创建了一个aspx页面,因为我有一些内容和一个按钮。当我点击按钮时,需要使用我的内容生成一个html页面。任何人都可以帮我动态生成html页面。

Hello to every body. I am new for creating html dynamically. My requirement is that, i created one aspx page, In that I have some content and one button. When i click the button one html page need to generate with my content. Can anyone help me to generate html pages dynamically.

推荐答案

最简单的方法是用<创建 String code> StringBuilder 类并将内容分配给它的对象。



参见一个示例 [ ^ ]。
The simplest way would be creating a String with StringBuilder Class and assign the contents to its object.

See one example[^].


使用像Razor这样的东西不适用于此?因为如果你使用视图引擎进行大量的html生成可以使它变得容易多了。它也是为在ASP.NET之外使用而构建的。



但有时这不是你需要的。您是否考虑使用属于.net(mvc)的TagBuilder类? System.Web.UI中还有HtmlWriter(用于Web表单)。如果您正在制作控件或Html助手,我会推荐其中一个
Is using something like Razor not applicable here? Because if you're doing a lot of html generation using a view engine can make it a lot easier. It was also built to be used outside of ASP.NET.

However sometimes that's not what you need. Have you considered using the TagBuilder class which is part of .net (mvc)? There is also the HtmlWriter in System.Web.UI (for web forms). I would recommend one of these if you are making Controls or Html Helpers


如何使用c#创建动态网页 [ ^ ]


这篇关于在c#中动态创建html页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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