实时HTML编辑 [英] Realtime HTML editing

查看:115
本文介绍了实时HTML编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对编程非常陌生,请保持谦虚.

我正在尝试创建一个将构建" Outlook HTML签名的程序.我正在严格的布局下工作,因此我将使用文本"框逐行控制用户可以输入的内容.我们也有通过URL提供的徽标.

我希望使用"WebBrowser"控件来显示HTML.我找到了教程,他们在本地磁盘上创建了一个HTML文件,然后显示了该文件,但我希望跳过该文件并直接从RAM中显示它.阅读完该控件后,我认为我可以使用WebBrowser.DocumentText = "<html><body>test</body></html>"类型格式直接对其进行写操作.不幸的是,我的WebBrowser组件仍然为空.我也尝试了调用Refresh方法,但仍然没有显示任何内容.

谁能告诉我我要去哪里错了?另外,作为菜鸟,您将如何设置呢?我有一个启用了组件的表单,然后创建了一个单独的类,该类保存在私有变量中输入的所有数据,并使用公共属性进行访问.我还将以这种形式创建一个方法,以创建和存储准备输出的HTML字符串.

非常感谢您的帮助.

谢谢

Hi,

I am very new to programming so please be gentle.

I am trying to create a program that will ''build'' an Outlook HTML signature. I am working to a strict layout so I will use Text boxes to control line-by-line what users can enter. We also have logos that are served via a URL.

I was hoping to use the "WebBrowser" control to display the HTML. I have found tutorials where they have created an HTML file on the local disk, then displayed it but I was hoping to skip that and display it straight from RAM. After reading about the control, I thought I would be able to write directly to it using WebBrowser.DocumentText = "<html><body>test</body></html>" type format. Unfortunately, my WebBrowser component remains blank. I have also tried a call to the Refresh method but still it did not show anything.

Could anyone tell me where I am going wrong? Also, as a noob, how would you set this up? I have a form with my components on, then created a separate class which holds all of the data entered in private variables, access using public properties. I will also create a method in this form to create and store the HTML string ready for outputting.

I''d really appreciate any help.

Thanks

推荐答案

我将为所有文本框的TextChanged事件分配一个方法.
这种方法看起来像这样

I would assign a method to the TextChanged event of all text boxes.

This method could look like this

private void textBox_TextChanged(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(textBox1.Text);
            sb.Append(textBox2.Text);
            webBrowser1.DocumentText = sb.ToString();
        }


这篇关于实时HTML编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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