我正在尝试使用一个类生成一个 HTML 文件,但它不会生成多个 HTML 标签,我想知道您是否可以告诉我我可以做什么才能在我的 HTML 文件中生成多个标签。这是代码:
public class GuidClass
{
public string htmlstringfirst = "<HTML><HEADER><title>My Web-page</title></HEADER><BODY>";
public string htmlstringend = "</form></BODY></HTML>";
public string htmlstring = "";
public GuidClass(string title, string type, string defaultvalue)
{
htmlstring += "\r\n<input id = " + '"' + System.Guid.NewGuid().ToString() + '"' + "title =" + '"' + title + '"' + "type=" + '"' + type + '"' + ">" + defaultvalue + "</input><br>";
}
}
private void button1_Click(object sender, EventArgs e)
{
GuidClass objGuid = new GuidClass(textBox1.Text, textBox2.Text, textBox3.Text);
using (FileStream fs = new FileStream(@"D:\test.htm", FileMode.Create))
{
using (StreamWriter writer = new StreamWriter(fs, Encoding.UTF8))
{
writer.Write(objGuid.htmlstringfirst + objGuid.htmlstring + objGuid.htmlstringend);
}
}
htmlLoadWebbrowser1.LoadHTML(@"D:\test.htm");
}