Solved

How can I create an html page programattically Can it be done?

Posted on 2007-04-05
4
192 Views
Last Modified: 2010-04-23
Can this be done ....

I simply want to create a html page that I can then display in a webBrowser control from a single button click ...

NOTE:  I would like to take the contentsd of around 6 textboxes that will be in the html page  such as a title, description and author name such like ....  then once the textboxes are filled click a button and the html page is created.
Then I want to display it in an webBrowser control  .....  I know how to display it once the html page is created ... its knowing how to create the html syntax for the page is where I am lost

All help is appreciated

Mark
0
Comment
Question by:vbMarkO
  • 2
4 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 18861012
At it's simplest...

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strHtml As New System.Text.StringBuilder
        strHtml.Append("<html><body>")
        strHtml.Append("<b>" & TextBox1.Text & "</b><br>") ' bold first line
        strHtml.Append(TextBox2.Text & "<br>")
        strHtml.Append(TextBox3.Text & "<br>")
        strHtml.Append("</body></html>")
        WebBrowser1.Navigate("about:" & strHtml.ToString)
    End Sub

End Class
0
 
LVL 27

Expert Comment

by:VBRocks
ID: 18862326
Just an additional comment:  You can write it out to a file with a ".html" extension.  If you write it out to an actual website directory, you'll be able to link to it as well.

Dim sw as New System.IO.StreamWriter("C:\MyPath\MyWebPage.html", False)
sw.WriteLine "<html>"
sw.WriteLine "<head>"
sw.WriteLine "<title>My Web Page Rocks!</title>"
sw.WriteLine "</head>"
sw.WriteLine "<body><h1>This is my page!</h1></body>"
sw.WriteLine "</html>"

sw.Close()
sw.Dispose()
0
 

Author Comment

by:vbMarkO
ID: 18862874
Ok I am giving these a go   running into soe trouble here it may be that this cant be done or more likely I ma just doing it all wrong ...

I am trying the first solution this way

strHtml.Append("<link" & "rel=" & ""stylesheet" " & "type=" & ""text/css" " & "href=" & ""style.css"" & " />")

The above is supposed to come out like below  ..... but I am getting a blue underline under stylesheet above

<link rel="stylesheet" type="text/css" href="style.css" />

I know this more complex than what you example was but can I do this with what you were doing?

Here is what I have before the above

strHtml.Append("<html><head>")
strHtml.Append("<title>" & "The Church of God Ministers Report" & "</title>") ' <title>The Church of God Minsiters Report</title>
THEN
strHtml.Append("<link" & "rel=" & ""stylesheet" " & "type=" & ""text/css" " & "href=" & ""style.css"" & " />")

this is where I am getting the error ... the blue underlinning stylesheet


0
 

Author Comment

by:vbMarkO
ID: 18862909
I fixed it and I find this solution to be my fix ....

strHtml.Append("<link rel=""stylesheet"" type=""text/css"" href=""style.css"" />")

That resolved my error ....

I appreciate showing how to write to an html file but the other is really what I am wanting  
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now