Well-Formed XML from Event Handers?

P

pbd22

Hi.

How do i output a well-formed XML document from inside an active event
handler? I tried this in VB.NET (using a stringbuilder) and I kept
getting a parser error. Has anybody run into this problem and what was
the solution?

I thank you.
Peter
 
M

Martin Honnen

pbd22 said:
How do i output a well-formed XML document from inside an active event
handler? I tried this in VB.NET (using a stringbuilder) and I kept
getting a parser error. Has anybody run into this problem and what was
the solution?

What kind of "event handler" are you talking about? Is that the ASP.NET
page model? What else does the page contain besides the code for the
event handler?
 
P

pbd22

What kind of "event handler" are you talking about? Is that the ASP.NET
page model? What else does the page contain besides the code for the
event handler?


Thanks for your reply Martin.

Its VB.NET/ASP.NET 2.0 and the event handler is a custom handler that
gets fired every time a byte is sent to a remote server for FTP. The
only
other method on the page is a Page_Load event that handles the upload
of the files. Below is the event handler. I currently get a parser
error becuase
it keeps recreating the XML every time the event handler fires and I
cant
figure out how to avoid this - I need to replace/update it, not append
to it.


Public Sub onIncrementCallback(ByVal sender As Object, ByVal e As
IncrementEventArgs)

Dim sbhtml As StringBuilder = New StringBuilder
sbhtml.Append("<?xml version='1.0' encoding='ISO-8859-1'?
sbhtml.Append("<uploads>")
sbhtml.Append("<upload>")
sbhtml.Append("<filename>")
sbhtml.Append(e.FileName)
sbhtml.Append("</filename>")
sbhtml.Append("<bytessent>")
sbhtml.Append(e.BytesSent)
sbhtml.Append("</bytessent>")
sbhtml.Append("<filesize>")
sbhtml.Append(e.TotalBytesToSend)
sbhtml.Append("</filesize>")
sbhtml.Append("<percent>")
sbhtml.Append(e.ProgressPercentage)
sbhtml.Append("</percent>")
sbhtml.Append("</upload>")
sbhtml.Append("</uploads>")
Context.Response.ContentType = "text/xml"
Response.Write(sbhtml.ToString)
End Sub

Thanks for your help,
Peter
 
M

Martin Honnen

pbd22 said:
it keeps recreating the XML every time the event handler fires and I
cant
figure out how to avoid this - I need to replace/update it, not append
to it.

Ask in an ASP.NET group or forum.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,602
Members
45,185
Latest member
GluceaReviews

Latest Threads

Top