Solved

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

Posted on 2007-04-05
4
194 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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