469,323 Members | 1,639 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Writing html files

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
6 21139
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
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
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
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
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
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.

Similar topics

reply views Thread by Dariusz | last post: by
3 posts views Thread by Ladykiller | last post: by
5 posts views Thread by nick | last post: by
2 posts views Thread by nick | last post: by
1 post views Thread by Michael Leithold, WWK | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.