Click here to Skip to main content
15,908,775 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

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

This method could look like this

C#
private void textBox_TextChanged(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(textBox1.Text);
            sb.Append(textBox2.Text);
            webBrowser1.DocumentText = sb.ToString();
        }
 
Share this answer
 
v2
Comments
Jim607 4-Apr-11 9:23am    
Ah, great, I was kind of doing your suggestion so I looked a bit harder into the setting on the webBrowser. I found that I had changed a property of the webBrowser which was stopping it working. I had assumed I was not using it properly. It was the property "Allow Navigation" that was set to False. I had previously followed an online tutorial which required it to be set to false. this obviously did not suit what I was trying to do.

Thanks for your help, I was unaware of the "string builder" so you have been a big help. It will tidy my code up loads and my webBrowser control works a treat now thanks again.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900