使用Winforms C#创建html文件 [英] creating a html file with winforms c#

查看:64
本文介绍了使用Winforms C#创建html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用c#.net win表单创建单个HTML页面.

我有存储在Db中的选项和值,当用户单击按钮创建HTML文件时,我想使用这些选项和值.


获取下拉菜单或单选按钮的选项和值很容易.但是如何动态创建HTML文件..

How can i create a single HTML page with c# .net win forms.

I have the options and values stored in Db which i want to use when user clicks the button to create a HTML file.


It is easy to fetch the options and values for drop down or radio buttons .But how do i create the HTML file dynamically ..

推荐答案

HTML是一个字符串.如果需要,您可以将mash HTML字符串化.但是,您希望此HTML到达何处?
HTML is a string. You can string mash HTML if you want to. Where do you expect this HTML to go, though ?


您可以使用Web浏览器控件作为解决方案.

首先从数据库中获取所有必需的数据,然后使用String Builder生成与我们在HTML页面中相同的代码.

一旦完成编码或字符串准备就绪.将该字符串分配给Web浏览器控件文档.

例如

Dim sStr作为新的StringBuider
sStr.Append(< HTML>您的所有代码在这里</HTML>")

WebBrowser1.Document = sStr.Tostring()

我认为这对您有用!
You can use Web Browser Control for your solution.

First fetch all required Data from DB then after use String Builder to generate code same like we have doing in HTML page.

Once you have done the coding or your string is ready. Assign that string to Web Browser Control Document.

E.g.

Dim sStr as New StringBuider
sStr.Append("<HTML>ALL YOUR CODE HERE</HTML>")

WebBrowser1.Document = sStr.Tostring()

I think this will work for you!


由于html是纯文本,因此只需使用记事本即可制作,因此您可以使用可处理字符串的任何内容制作html.请注意,html不是xml,xhtml也不总是xml(演讲: https ://www.webkit.org/blog/68/understanding-html-xml-and-xhtml/ [ HTML Agility Pack [ ^ ].如果您托盘分析现有的html或xhtml文件,则此功能更有用,但如果要创建一个文件,它也将非常有用.
As html is a plain text, can be made with just a notepad, so you can make html with anything that can handle strings. Be aware, that html is not xml, and neither xhtml is always xml (lecture: https://www.webkit.org/blog/68/understanding-html-xml-and-xhtml/[^]) - I suggest you treat it what it is.
So you either write the text on your own based on the standard specifications, or you can use a DOM modeler, like HTML Agility Pack[^]. This one is more useful if you tray to parse an existing html or xhtml file, but it is also usefull if you want to create one.


这篇关于使用Winforms C#创建html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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