Solved

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

Posted on 2007-04-05
4
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

630 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