[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Troy Busot

1/13/2003 11:23:00 PM

I'm trying to capture the contents of a Repeater object and write it to a
file and still show the repeater on screen.

StreamWriter writer = new StreamWriter( @"c:\write\output.txt" );
HtmlTextWriter hWriter = new HtmlTextWriter( writer );
repeater.RenderControl( hWriter );

Doing the above code almost works. I get the repeater written to the screen
perfectly, but there are two problems:
1) When I call RenderControl(), the repeater outputs some of the text to
the screen. So outside of the actual Repeater output (which is good), I get
some extra content from the repeater to show up on screen.

2) Exactly 4k gets written to the file - that's it. I can specify a
buffer size in while creating the StreamWriter object, but it just seems to
bounce between 3K and 4K - not sure what I'm doing wrong here.

Any thoughts?

Thanks.
Troy Busot



6 Answers

(Mike Moore [MS])

1/14/2003 4:54:00 AM

0

Hi Troy,

The code-behind is actually an abstract class. It can't do anything by
itself. The ASPX page inherits the code-behind. The ASPX page then runs as
itself, which includes everything it inherited from the code-behind. Again,
the code-behind doesn't do anything. It's the object that inherits the
code-behind that actually runs.

So, now you have some code that simply tells the repeater control to render
itself. The ASPX page inherits this along with the rest of he code-behind.
Then someone browses the page. When it gets to the line of code to render
the repeater control, it does call the repeater's render function. However,
the control's render function expects to be inside a hierarchy of controls
which includes a parent form control. The page's render event does all this
work in the expected order. It parses the ASPX page and creates objects
representing each server object. It adds sub-controls to the controls
collections of parent controls. When all the controls are in place, they
each are nested appropriately.

I'll look into this more tomorrow.

Thank you, Mike Moore
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
>From: "Troy Busot" <troy@busot.com>
>Subject: Render a repeater to a file?
>Date: Mon, 13 Jan 2003 15:23:11 -0700
>Lines: 24
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>Message-ID: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>NNTP-Posting-Host: hawk73.t-bird.edu 192.160.35.73
>Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP10
>Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webcontrols:8492
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>
>I'm trying to capture the contents of a Repeater object and write it to a
>file and still show the repeater on screen.
>
> StreamWriter writer = new StreamWriter( @"c:\write\output.txt" );
> HtmlTextWriter hWriter = new HtmlTextWriter( writer );
> repeater.RenderControl( hWriter );
>
>Doing the above code almost works. I get the repeater written to the screen
>perfectly, but there are two problems:
> 1) When I call RenderControl(), the repeater outputs some of the text
to
>the screen. So outside of the actual Repeater output (which is good), I get
>some extra content from the repeater to show up on screen.
>
> 2) Exactly 4k gets written to the file - that's it. I can specify a
>buffer size in while creating the StreamWriter object, but it just seems to
>bounce between 3K and 4K - not sure what I'm doing wrong here.
>
>Any thoughts?
>
>Thanks.
>Troy Busot
>
>
>
>

(Mike Moore [MS])

1/14/2003 5:28:00 AM

0

There's another active thread with about the same question:
From: "Troy Busot" <troy@busot.com>
Subject: Render a repeater to a file?
Date: Mon, 13 Jan 2003 15:23:11 -0700
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols

Troy started the thread and Scott replied (copy below). Scott's reply comes
out to be very similar to the three lines you already posted. Troy also
responded that this caused a problem because the inner text boxes need to
be inside a form.


From: "Scott Mitchell [MVP]" <smitchell@internet.com>
Newsgroups: microsoft.public.dotnet.framework.aspnet
Subject: Re: WebControls to HTML Text
Date: Mon, 13 Jan 2003 19:22:26 GMT

Joe Curry wrote:
> Is there a way to convert a System.Web.UI.WebControls.Table to xml or
text.

Check out the following article:

Emailing the Rendered Output of an ASP.NET Web Control
http://aspnet.4guysfromrolla.com/articles/091...

Specifically, pay attention to the section titled "Retrieving a
Control's Rendered HTML in an ASP.NET Page."

** end of post from Scott **


Thank you, Mike Moore
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
>From: "Troy Busot" <troy@busot.com>
>Subject: Render a repeater to a file?
>Date: Mon, 13 Jan 2003 15:23:11 -0700
>Lines: 24
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>Message-ID: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>NNTP-Posting-Host: hawk73.t-bird.edu 192.160.35.73
>Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP10
>Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webcontrols:8492
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>
>I'm trying to capture the contents of a Repeater object and write it to a
>file and still show the repeater on screen.
>
> StreamWriter writer = new StreamWriter( @"c:\write\output.txt" );
> HtmlTextWriter hWriter = new HtmlTextWriter( writer );
> repeater.RenderControl( hWriter );
>
>Doing the above code almost works. I get the repeater written to the screen
>perfectly, but there are two problems:
> 1) When I call RenderControl(), the repeater outputs some of the text
to
>the screen. So outside of the actual Repeater output (which is good), I get
>some extra content from the repeater to show up on screen.
>
> 2) Exactly 4k gets written to the file - that's it. I can specify a
>buffer size in while creating the StreamWriter object, but it just seems to
>bounce between 3K and 4K - not sure what I'm doing wrong here.
>
>Any thoughts?
>
>Thanks.
>Troy Busot
>
>
>
>

(Mike Moore [MS])

1/15/2003 3:36:00 AM

0

Hi Troy,

I apologize for the delay. I plan to look into this further tomorrow.

Thank you, Mike Moore
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
>X-Tomcat-ID: 106336921
>References: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>MIME-Version: 1.0
>Content-Type: text/plain
>Content-Transfer-Encoding: 7bit
>From: michmo@online.microsoft.com ("Mike Moore [MS]")
>Organization: Microsoft
>Date: Tue, 14 Jan 2003 04:28:28 GMT
>Subject: RE: Render a repeater to a file?
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>Message-ID: <d6YuaV4uCHA.3108@cpmsftngxa06>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>Lines: 72
>Path: cpmsftngxa06
>Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webcontrols:8499
>NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
>
>There's another active thread with about the same question:
> From: "Troy Busot" <troy@busot.com>
> Subject: Render a repeater to a file?
> Date: Mon, 13 Jan 2003 15:23:11 -0700
> Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>
>Troy started the thread and Scott replied (copy below). Scott's reply
comes
>out to be very similar to the three lines you already posted. Troy also
>responded that this caused a problem because the inner text boxes need to
>be inside a form.
>
>
>From: "Scott Mitchell [MVP]" <smitchell@internet.com>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Subject: Re: WebControls to HTML Text
>Date: Mon, 13 Jan 2003 19:22:26 GMT
>
>Joe Curry wrote:
>> Is there a way to convert a System.Web.UI.WebControls.Table to xml or
>text.
>
>Check out the following article:
>
> Emailing the Rendered Output of an ASP.NET Web Control
> http://aspnet.4guysfromrolla.com/articles/091...
>
>Specifically, pay attention to the section titled "Retrieving a
>Control's Rendered HTML in an ASP.NET Page."
>
>** end of post from Scott **
>
>
>Thank you, Mike Moore
>Microsoft, ASP.NET
>
>This posting is provided "AS IS", with no warranties, and confers no
rights.
>
>--------------------
>>From: "Troy Busot" <troy@busot.com>
>>Subject: Render a repeater to a file?
>>Date: Mon, 13 Jan 2003 15:23:11 -0700
>>Lines: 24
>>X-Priority: 3
>>X-MSMail-Priority: Normal
>>X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
>>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>>Message-ID: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>NNTP-Posting-Host: hawk73.t-bird.edu 192.160.35.73
>>Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP10
>>Xref: cpmsftngxa06
>microsoft.public.dotnet.framework.aspnet.webcontrols:8492
>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>>
>>I'm trying to capture the contents of a Repeater object and write it to a
>>file and still show the repeater on screen.
>>
>> StreamWriter writer = new StreamWriter( @"c:\write\output.txt" );
>> HtmlTextWriter hWriter = new HtmlTextWriter( writer );
>> repeater.RenderControl( hWriter );
>>
>>Doing the above code almost works. I get the repeater written to the
screen
>>perfectly, but there are two problems:
>> 1) When I call RenderControl(), the repeater outputs some of the text
>to
>>the screen. So outside of the actual Repeater output (which is good), I
get
>>some extra content from the repeater to show up on screen.
>>
>> 2) Exactly 4k gets written to the file - that's it. I can specify a
>>buffer size in while creating the StreamWriter object, but it just seems
to
>>bounce between 3K and 4K - not sure what I'm doing wrong here.
>>
>>Any thoughts?
>>
>>Thanks.
>>Troy Busot
>>
>>
>>
>>
>
>

(Mike Moore [MS])

1/16/2003 5:32:00 AM

0

Hi Troy,

I've been looking at this and I'm still stumped. I can get the HTML for the
whole document, but not for just the repeater. I'll continue tomorrow.

Thank you, Mike Moore
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
>X-Tomcat-ID: 63869594
>References: <#U4ySJ1uCHA.1096@TK2MSFTNGP10> <d6YuaV4uCHA.3108@cpmsftngxa06>
>MIME-Version: 1.0
>Content-Type: text/plain
>Content-Transfer-Encoding: 7bit
>From: michmo@online.microsoft.com ("Mike Moore [MS]")
>Organization: Microsoft
>Date: Wed, 15 Jan 2003 02:36:43 GMT
>Subject: RE: Render a repeater to a file?
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>Message-ID: <seI0o7DvCHA.1340@cpmsftngxa09>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>Lines: 97
>Path: cpmsftngxa09
>Xref: cpmsftngxa09
microsoft.public.dotnet.framework.aspnet.webcontrols:8523
>NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
>
>Hi Troy,
>
>I apologize for the delay. I plan to look into this further tomorrow.
>
>Thank you, Mike Moore
>Microsoft, ASP.NET
>
>This posting is provided "AS IS", with no warranties, and confers no
rights.
>
>--------------------
>>X-Tomcat-ID: 106336921
>>References: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>>MIME-Version: 1.0
>>Content-Type: text/plain
>>Content-Transfer-Encoding: 7bit
>>From: michmo@online.microsoft.com ("Mike Moore [MS]")
>>Organization: Microsoft
>>Date: Tue, 14 Jan 2003 04:28:28 GMT
>>Subject: RE: Render a repeater to a file?
>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>>Message-ID: <d6YuaV4uCHA.3108@cpmsftngxa06>
>>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>Lines: 72
>>Path: cpmsftngxa06
>>Xref: cpmsftngxa06
>microsoft.public.dotnet.framework.aspnet.webcontrols:8499
>>NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
>>
>>There's another active thread with about the same question:
>> From: "Troy Busot" <troy@busot.com>
>> Subject: Render a repeater to a file?
>> Date: Mon, 13 Jan 2003 15:23:11 -0700
>> Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>
>>Troy started the thread and Scott replied (copy below). Scott's reply
>comes
>>out to be very similar to the three lines you already posted. Troy also
>>responded that this caused a problem because the inner text boxes need to
>>be inside a form.
>>
>>
>>From: "Scott Mitchell [MVP]" <smitchell@internet.com>
>>Newsgroups: microsoft.public.dotnet.framework.aspnet
>>Subject: Re: WebControls to HTML Text
>>Date: Mon, 13 Jan 2003 19:22:26 GMT
>>
>>Joe Curry wrote:
>>> Is there a way to convert a System.Web.UI.WebControls.Table to xml or
>>text.
>>
>>Check out the following article:
>>
>> Emailing the Rendered Output of an ASP.NET Web Control
>> http://aspnet.4guysfromrolla.com/articles/091...
>>
>>Specifically, pay attention to the section titled "Retrieving a
>>Control's Rendered HTML in an ASP.NET Page."
>>
>>** end of post from Scott **
>>
>>
>>Thank you, Mike Moore
>>Microsoft, ASP.NET
>>
>>This posting is provided "AS IS", with no warranties, and confers no
>rights.
>>
>>--------------------
>>>From: "Troy Busot" <troy@busot.com>
>>>Subject: Render a repeater to a file?
>>>Date: Mon, 13 Jan 2003 15:23:11 -0700
>>>Lines: 24
>>>X-Priority: 3
>>>X-MSMail-Priority: Normal
>>>X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
>>>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>>>Message-ID: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>>>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>>NNTP-Posting-Host: hawk73.t-bird.edu 192.160.35.73
>>>Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP10
>>>Xref: cpmsftngxa06
>>microsoft.public.dotnet.framework.aspnet.webcontrols:8492
>>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>>>
>>>I'm trying to capture the contents of a Repeater object and write it to a
>>>file and still show the repeater on screen.
>>>
>>> StreamWriter writer = new StreamWriter( @"c:\write\output.txt" );
>>> HtmlTextWriter hWriter = new HtmlTextWriter( writer );
>>> repeater.RenderControl( hWriter );
>>>
>>>Doing the above code almost works. I get the repeater written to the
>screen
>>>perfectly, but there are two problems:
>>> 1) When I call RenderControl(), the repeater outputs some of the
text
>>to
>>>the screen. So outside of the actual Repeater output (which is good), I
>get
>>>some extra content from the repeater to show up on screen.
>>>
>>> 2) Exactly 4k gets written to the file - that's it. I can specify a
>>>buffer size in while creating the StreamWriter object, but it just seems
>to
>>>bounce between 3K and 4K - not sure what I'm doing wrong here.
>>>
>>>Any thoughts?
>>>
>>>Thanks.
>>>Troy Busot
>>>
>>>
>>>
>>>
>>
>>
>
>

(Mike Moore [MS])

1/17/2003 3:16:00 AM

0

Hi Troy,

I found that it is easy to get the DATA from the repeater. Whatever you
have the repeater bound to, add some code to copy that data to where ever
you want. Or, use the repeater's ItemCreated event to capture the data.

I found that is hard to get the HTML from the repeater. I tried creating my
own MyForm class which inherits from HtmlForm and I overrode RenderChildren
inside my class. Then I used this substitute form in my page that contains
the repeater. It did not work.

It appears that the easiest way is to override the Render event in the
code-behind and use code like you used in your initial post for this thread.

Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
Dim s_wtr As New StringWriter()
Dim h_wtr As HtmlTextWriter = New HtmlTextWriter(s_wtr)
MyBase.Render(h_wtr)
h_wtr.Close()
Dim f_wtr As StreamWriter = New StreamWriter("c:\repeater1.txt")
f_wtr.Write(s_wtr.ToString)
f_wtr.Close()
writer.Write(s_wtr.ToString)
s_wtr.Close()
End Sub

The above writes out the HTML to both the requesting client and the
server's hard drive. However, this is the whole HTML document, not just the
repeater. The next step is to add text manipulation code, prior to saving
to disk, which extracts just the HTML for the repeater. This could be done
by adding some extra tag (perhaps a span tag) around the repeater. Then the
text manipulation code could use that tag a marker for the beginning and
ending of the HTML for the repeater.

I hope this helps.

Thank you, Mike Moore
Microsoft, ASP.NET

This posting is provided "AS IS", with no warranties, and confers no rights.

--------------------
>X-Tomcat-ID: 98783899
>References: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
<d6YuaV4uCHA.3108@cpmsftngxa06> <seI0o7DvCHA.1340@cpmsftngxa09>
>MIME-Version: 1.0
>Content-Type: text/plain
>Content-Transfer-Encoding: 7bit
>From: michmo@online.microsoft.com ("Mike Moore [MS]")
>Organization: Microsoft
>Date: Thu, 16 Jan 2003 04:32:28 GMT
>Subject: RE: Render a repeater to a file?
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>Message-ID: <swFcChRvCHA.3284@cpmsftngxa06>
>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>Lines: 125
>Path: cpmsftngxa06
>Xref: cpmsftngxa06
microsoft.public.dotnet.framework.aspnet.webcontrols:8562
>NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
>
>Hi Troy,
>
>I've been looking at this and I'm still stumped. I can get the HTML for
the
>whole document, but not for just the repeater. I'll continue tomorrow.
>
>Thank you, Mike Moore
>Microsoft, ASP.NET
>
>This posting is provided "AS IS", with no warranties, and confers no
rights.
>
>--------------------
>>X-Tomcat-ID: 63869594
>>References: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
<d6YuaV4uCHA.3108@cpmsftngxa06>
>>MIME-Version: 1.0
>>Content-Type: text/plain
>>Content-Transfer-Encoding: 7bit
>>From: michmo@online.microsoft.com ("Mike Moore [MS]")
>>Organization: Microsoft
>>Date: Wed, 15 Jan 2003 02:36:43 GMT
>>Subject: RE: Render a repeater to a file?
>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>>Message-ID: <seI0o7DvCHA.1340@cpmsftngxa09>
>>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>Lines: 97
>>Path: cpmsftngxa09
>>Xref: cpmsftngxa09
>microsoft.public.dotnet.framework.aspnet.webcontrols:8523
>>NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
>>
>>Hi Troy,
>>
>>I apologize for the delay. I plan to look into this further tomorrow.
>>
>>Thank you, Mike Moore
>>Microsoft, ASP.NET
>>
>>This posting is provided "AS IS", with no warranties, and confers no
>rights.
>>
>>--------------------
>>>X-Tomcat-ID: 106336921
>>>References: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>>>MIME-Version: 1.0
>>>Content-Type: text/plain
>>>Content-Transfer-Encoding: 7bit
>>>From: michmo@online.microsoft.com ("Mike Moore [MS]")
>>>Organization: Microsoft
>>>Date: Tue, 14 Jan 2003 04:28:28 GMT
>>>Subject: RE: Render a repeater to a file?
>>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>>>Message-ID: <d6YuaV4uCHA.3108@cpmsftngxa06>
>>>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>>Lines: 72
>>>Path: cpmsftngxa06
>>>Xref: cpmsftngxa06
>>microsoft.public.dotnet.framework.aspnet.webcontrols:8499
>>>NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
>>>
>>>There's another active thread with about the same question:
>>> From: "Troy Busot" <troy@busot.com>
>>> Subject: Render a repeater to a file?
>>> Date: Mon, 13 Jan 2003 15:23:11 -0700
>>> Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>>
>>>Troy started the thread and Scott replied (copy below). Scott's reply
>>comes
>>>out to be very similar to the three lines you already posted. Troy also
>>>responded that this caused a problem because the inner text boxes need
to
>>>be inside a form.
>>>
>>>
>>>From: "Scott Mitchell [MVP]" <smitchell@internet.com>
>>>Newsgroups: microsoft.public.dotnet.framework.aspnet
>>>Subject: Re: WebControls to HTML Text
>>>Date: Mon, 13 Jan 2003 19:22:26 GMT
>>>
>>>Joe Curry wrote:
>>>> Is there a way to convert a System.Web.UI.WebControls.Table to xml or
>>>text.
>>>
>>>Check out the following article:
>>>
>>> Emailing the Rendered Output of an ASP.NET Web Control
>>> http://aspnet.4guysfromrolla.com/articles/091...
>>>
>>>Specifically, pay attention to the section titled "Retrieving a
>>>Control's Rendered HTML in an ASP.NET Page."
>>>
>>>** end of post from Scott **
>>>
>>>
>>>Thank you, Mike Moore
>>>Microsoft, ASP.NET
>>>
>>>This posting is provided "AS IS", with no warranties, and confers no
>>rights.
>>>
>>>--------------------
>>>>From: "Troy Busot" <troy@busot.com>
>>>>Subject: Render a repeater to a file?
>>>>Date: Mon, 13 Jan 2003 15:23:11 -0700
>>>>Lines: 24
>>>>X-Priority: 3
>>>>X-MSMail-Priority: Normal
>>>>X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
>>>>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
>>>>Message-ID: <#U4ySJ1uCHA.1096@TK2MSFTNGP10>
>>>>Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
>>>>NNTP-Posting-Host: hawk73.t-bird.edu 192.160.35.73
>>>>Path: cpmsftngxa06!TK2MSFTNGP08!TK2MSFTNGP10
>>>>Xref: cpmsftngxa06
>>>microsoft.public.dotnet.framework.aspnet.webcontrols:8492
>>>>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
>>>>
>>>>I'm trying to capture the contents of a Repeater object and write it to
a
>>>>file and still show the repeater on screen.
>>>>
>>>> StreamWriter writer = new StreamWriter( @"c:\write\output.txt" );
>>>> HtmlTextWriter hWriter = new HtmlTextWriter( writer );
>>>> repeater.RenderControl( hWriter );
>>>>
>>>>Doing the above code almost works. I get the repeater written to the
>>screen
>>>>perfectly, but there are two problems:
>>>> 1) When I call RenderControl(), the repeater outputs some of the
>text
>>>to
>>>>the screen. So outside of the actual Repeater output (which is good), I
>>get
>>>>some extra content from the repeater to show up on screen.
>>>>
>>>> 2) Exactly 4k gets written to the file - that's it. I can specify a
>>>>buffer size in while creating the StreamWriter object, but it just
seems
>>to
>>>>bounce between 3K and 4K - not sure what I'm doing wrong here.
>>>>
>>>>Any thoughts?
>>>>
>>>>Thanks.
>>>>Troy Busot
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>

unknown

1/17/2003 8:59:00 AM

0

You have to close the stream or the buffer isn't written. Add
hWriter.Close(); to the existing code.

McGiv

"Troy Busot" <troy@busot.com> wrote in message
news:#U4ySJ1uCHA.1096@TK2MSFTNGP10...
> I'm trying to capture the contents of a Repeater object and write it to a
> file and still show the repeater on screen.
>
> StreamWriter writer = new StreamWriter( @"c:\write\output.txt" );
> HtmlTextWriter hWriter = new HtmlTextWriter( writer );
> repeater.RenderControl( hWriter );
>
> Doing the above code almost works. I get the repeater written to the
screen
> perfectly, but there are two problems:
> 1) When I call RenderControl(), the repeater outputs some of the text
to
> the screen. So outside of the actual Repeater output (which is good), I
get
> some extra content from the repeater to show up on screen.
>
> 2) Exactly 4k gets written to the file - that's it. I can specify a
> buffer size in while creating the StreamWriter object, but it just seems
to
> bounce between 3K and 4K - not sure what I'm doing wrong here.
>
> Any thoughts?
>
> Thanks.
> Troy Busot
>
>
>