By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,272 Members | 1,403 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,272 IT Pros & Developers. It's quick & easy.

Writing html files

P: n/a
guy
Does .NET have a class or set of functions that facilitate the creating and
writing of html files?

I have been creating files in streams and constructing html strings and
writing them out but it seems that a class could facilitate this better.

Thanks
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi. Check out the HtmlWriter class.
John Puopolo

"guy" <wi*********@hotmail.com> wrote in message
news:Oq****************@TK2MSFTNGP10.phx.gbl...
Does .NET have a class or set of functions that facilitate the creating and writing of html files?

I have been creating files in streams and constructing html strings and
writing them out but it seems that a class could facilitate this better.

Thanks

Nov 16 '05 #2

P: n/a
Hi Guy,

HtmlTextWriter looks like it could help:

using System;
using System.IO;
using System.Text;
using System.Web.UI;

public class Test
{
public static void Main()
{
StringBuilder strBldr = new StringBuilder();
StringWriter strWriter = new StringWriter(strBldr);

HtmlTextWriter writer = new HtmlTextWriter(strWriter);

//<html>
writer.RenderBeginTag(HtmlTextWriterTag.Html);

// <head>
writer.RenderBeginTag(HtmlTextWriterTag.Head);

// </head>
writer.RenderEndTag();

// <body>
writer.RenderBeginTag(HtmlTextWriterTag.Body);

writer.Write("This is text for my web page.");

// </body>
writer.RenderEndTag();

// </html>
writer.RenderEndTag();

Console.WriteLine(strBldr.ToString());
}
}

Joe
--
http://www.csharp-station.com

"guy" <wi*********@hotmail.com> wrote in message
news:Oq****************@TK2MSFTNGP10.phx.gbl...
Does .NET have a class or set of functions that facilitate the creating
and writing of html files?

I have been creating files in streams and constructing html strings and
writing them out but it seems that a class could facilitate this better.

Thanks

Nov 16 '05 #3

P: n/a
guy
Thanks.

"Joe Mayo" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:uv****************@TK2MSFTNGP09.phx.gbl...
Hi Guy,

HtmlTextWriter looks like it could help:

using System;
using System.IO;
using System.Text;
using System.Web.UI;

public class Test
{
public static void Main()
{
StringBuilder strBldr = new StringBuilder();
StringWriter strWriter = new StringWriter(strBldr);

HtmlTextWriter writer = new HtmlTextWriter(strWriter);

//<html>
writer.RenderBeginTag(HtmlTextWriterTag.Html);

// <head>
writer.RenderBeginTag(HtmlTextWriterTag.Head);

// </head>
writer.RenderEndTag();

// <body>
writer.RenderBeginTag(HtmlTextWriterTag.Body);

writer.Write("This is text for my web page.");

// </body>
writer.RenderEndTag();

// </html>
writer.RenderEndTag();

Console.WriteLine(strBldr.ToString());
}
}

Joe
--
http://www.csharp-station.com

"guy" <wi*********@hotmail.com> wrote in message
news:Oq****************@TK2MSFTNGP10.phx.gbl...
Does .NET have a class or set of functions that facilitate the creating
and writing of html files?

I have been creating files in streams and constructing html strings and
writing them out but it seems that a class could facilitate this better.

Thanks


Nov 16 '05 #4

P: n/a
guy
Thanks.

"John Puopolo" <jo**********@fastsearch.com.nospam> wrote in message
news:e3****************@TK2MSFTNGP12.phx.gbl...
Hi. Check out the HtmlWriter class.
John Puopolo

"guy" <wi*********@hotmail.com> wrote in message
news:Oq****************@TK2MSFTNGP10.phx.gbl...
Does .NET have a class or set of functions that facilitate the creating

and
writing of html files?

I have been creating files in streams and constructing html strings and
writing them out but it seems that a class could facilitate this better.

Thanks


Nov 16 '05 #5

P: n/a
guy
It looks like you can only use HtmlTextWriter if you're writing an ASP.NET
app. This is just a normal windows forms app and I want to put some of my
result out in HTML format such that they can be loaded onto the net at a
later stage or view with a browser.

"Joe Mayo" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:uv****************@TK2MSFTNGP09.phx.gbl...
Hi Guy,

HtmlTextWriter looks like it could help:

using System;
using System.IO;
using System.Text;
using System.Web.UI;

public class Test
{
public static void Main()
{
StringBuilder strBldr = new StringBuilder();
StringWriter strWriter = new StringWriter(strBldr);

HtmlTextWriter writer = new HtmlTextWriter(strWriter);

//<html>
writer.RenderBeginTag(HtmlTextWriterTag.Html);

// <head>
writer.RenderBeginTag(HtmlTextWriterTag.Head);

// </head>
writer.RenderEndTag();

// <body>
writer.RenderBeginTag(HtmlTextWriterTag.Body);

writer.Write("This is text for my web page.");

// </body>
writer.RenderEndTag();

// </html>
writer.RenderEndTag();

Console.WriteLine(strBldr.ToString());
}
}

Joe
--
http://www.csharp-station.com

"guy" <wi*********@hotmail.com> wrote in message
news:Oq****************@TK2MSFTNGP10.phx.gbl...
Does .NET have a class or set of functions that facilitate the creating
and writing of html files?

I have been creating files in streams and constructing html strings and
writing them out but it seems that a class could facilitate this better.

Thanks


Nov 16 '05 #6

P: n/a
guy
I was being stupid. Forgot to add System.Web to resources.

"guy" <wi*********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
It looks like you can only use HtmlTextWriter if you're writing an ASP.NET
app. This is just a normal windows forms app and I want to put some of my
result out in HTML format such that they can be loaded onto the net at a
later stage or view with a browser.

"Joe Mayo" <jm***@nospamAtCSharpDashStation.com> wrote in message
news:uv****************@TK2MSFTNGP09.phx.gbl...
Hi Guy,

HtmlTextWriter looks like it could help:

using System;
using System.IO;
using System.Text;
using System.Web.UI;

public class Test
{
public static void Main()
{
StringBuilder strBldr = new StringBuilder();
StringWriter strWriter = new StringWriter(strBldr);

HtmlTextWriter writer = new HtmlTextWriter(strWriter);

//<html>
writer.RenderBeginTag(HtmlTextWriterTag.Html);

// <head>
writer.RenderBeginTag(HtmlTextWriterTag.Head);

// </head>
writer.RenderEndTag();

// <body>
writer.RenderBeginTag(HtmlTextWriterTag.Body);

writer.Write("This is text for my web page.");

// </body>
writer.RenderEndTag();

// </html>
writer.RenderEndTag();

Console.WriteLine(strBldr.ToString());
}
}

Joe
--
http://www.csharp-station.com

"guy" <wi*********@hotmail.com> wrote in message
news:Oq****************@TK2MSFTNGP10.phx.gbl...
Does .NET have a class or set of functions that facilitate the creating
and writing of html files?

I have been creating files in streams and constructing html strings and
writing them out but it seems that a class could facilitate this better.

Thanks



Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.