Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-04-05
4
Medium Priority
?
199 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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