473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Ajax Update Progress control

I am trying to apply the Update Progress control to a method that is
building a zip file and then giving the user the chance to save the file
via a popup box. But the Update Progress control doesn't seem to like
this. I am getting the error :

'Sys.WebForms.PageRequestManagerParserErrorExcepti on. The message
received from the server could not be parsed. Common causes for this
error are when the response is modified by calls to Response.Write(),
response filter, Http Modules, or server trace is enabled'

Here is my code :

private void BuildZip(string ZipName)

{

//try

//{

string strZipFullPath =
(string)ConfigurationManager.AppSettings["ZipCreateLocation"].ToString()
+ "\\" + ZipName.ToString();

// 'using' statements gaurantee the stream is closed properly which is a
big source

// of problems otherwise. Its exception safe as well which is great.

using (ZipOutputStream s = new
ZipOutputStream(File.Create(strZipFullPath)))

{

s.SetLevel(9); // 0 - store only to 9 - means best compression

byte[] buffer = new byte[4096];

foreach (GridViewRow gvr in Results.Rows)

{

CheckBox chkBox = (CheckBox)gvr.FindControl("RowLevelCheckBox");

if (chkBox.Checked == true)

{

string strFilename = gvr.Cells[0].Text.ToString();

string strFullPath = Session["Location"] + "\\" + strFilename;

ZipEntry entry = new ZipEntry(Path.GetFileName(strFullPath));

entry.DateTime = DateTime.Now;

s.PutNextEntry(entry);

using (FileStream fs = File.OpenRead(strFullPath))

{

// Using a fixed size buffer here makes no noticeable difference for
output

// but keeps a lid on memory usage.

int sourceBytes;

do

{

sourceBytes = fs.Read(buffer, 0, buffer.Length);

s.Write(buffer, 0, sourceBytes);

}

while (sourceBytes 0);

}

}

}

// Finish/Close arent needed strictly as the using statement does this
automatically

// Finish is important to ensure trailing information for a Zip file is
appended. Without this

// the created file would be invalid.

s.Finish();

// Close is important to wrap things up and unlock the file.

s.Close();

FileStream fs1 = File.Open(strZipFullPath, FileMode.Open);

byte[] newbyte = new byte[fs1.Length];

fs1.Read(newbyte, 0, Convert.ToInt32(fs1.Length));

fs1.Close();

//delete file created on web server

File.Delete(strZipFullPath);

Response.AddHeader("Content-Disposition", "attachment; filename=" +
strZipFullPath);

//Response.OutputStream = "application/octect-stream";

Response.BinaryWrite(newbyte);

Response.End();

}

Any assistance would be really appreciated.

*** Sent via Developersdex http://www.developersdex.com ***
May 24 '07 #1
1 3265
the update panel and progress control can not be used with this
scenario. they postback to the page and expect a specially formated xml
response that they parse, thus your message.

also as xmlhttprequest is used to do the fetch, there would be no way
for the user to save the file (say you placed it in a form field) as
javascript does not have permission to write a file.

to do this you need to use a link to download to a new target window,
then using ajax poll the server to see if the download is done (be sure
session is off on the download page or you will not be able to poll
during the download).
-- bruce (sqlwork.com)

Mike P wrote:
I am trying to apply the Update Progress control to a method that is
building a zip file and then giving the user the chance to save the file
via a popup box. But the Update Progress control doesn't seem to like
this. I am getting the error :

'Sys.WebForms.PageRequestManagerParserErrorExcepti on. The message
received from the server could not be parsed. Common causes for this
error are when the response is modified by calls to Response.Write(),
response filter, Http Modules, or server trace is enabled'

Here is my code :

private void BuildZip(string ZipName)

{

//try

//{

string strZipFullPath =
(string)ConfigurationManager.AppSettings["ZipCreateLocation"].ToString()
+ "\\" + ZipName.ToString();

// 'using' statements gaurantee the stream is closed properly which is a
big source

// of problems otherwise. Its exception safe as well which is great.

using (ZipOutputStream s = new
ZipOutputStream(File.Create(strZipFullPath)))

{

s.SetLevel(9); // 0 - store only to 9 - means best compression

byte[] buffer = new byte[4096];

foreach (GridViewRow gvr in Results.Rows)

{

CheckBox chkBox = (CheckBox)gvr.FindControl("RowLevelCheckBox");

if (chkBox.Checked == true)

{

string strFilename = gvr.Cells[0].Text.ToString();

string strFullPath = Session["Location"] + "\\" + strFilename;

ZipEntry entry = new ZipEntry(Path.GetFileName(strFullPath));

entry.DateTime = DateTime.Now;

s.PutNextEntry(entry);

using (FileStream fs = File.OpenRead(strFullPath))

{

// Using a fixed size buffer here makes no noticeable difference for
output

// but keeps a lid on memory usage.

int sourceBytes;

do

{

sourceBytes = fs.Read(buffer, 0, buffer.Length);

s.Write(buffer, 0, sourceBytes);

}

while (sourceBytes 0);

}

}

}

// Finish/Close arent needed strictly as the using statement does this
automatically

// Finish is important to ensure trailing information for a Zip file is
appended. Without this

// the created file would be invalid.

s.Finish();

// Close is important to wrap things up and unlock the file.

s.Close();

FileStream fs1 = File.Open(strZipFullPath, FileMode.Open);

byte[] newbyte = new byte[fs1.Length];

fs1.Read(newbyte, 0, Convert.ToInt32(fs1.Length));

fs1.Close();

//delete file created on web server

File.Delete(strZipFullPath);

Response.AddHeader("Content-Disposition", "attachment; filename=" +
strZipFullPath);

//Response.OutputStream = "application/octect-stream";

Response.BinaryWrite(newbyte);

Response.End();

}

Any assistance would be really appreciated.

*** Sent via Developersdex http://www.developersdex.com ***
May 24 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: darrel | last post by:
I've been playing with prototype.js and scriptaculous to create some nice drag-and-drop interaction on my applications GUI. That's working well. Now I want to take the next step and start passing...
4
by: Bruno Alexandre | last post by:
Hi guys, I have this page that needs to be populated with 2 diferent web services, and each one takes more or less 10 seconds to finish populate his own part, so I move on to the multi threading...
8
by: =?Utf-8?B?R3JlZyBMYXJzZW4=?= | last post by:
I'm trying to figure out how to modify a panel (panel1) from a backgroundworker thread. But can't get the panel to show the new controls added by the backgroundwork task. Here is my code. In...
3
by: =?Utf-8?B?cGlja2VkYW5hbWU=?= | last post by:
Hi All, I have a progress update control and using the alwaysvisiblecontrol so that my progress indicator shows up without impacting my page layout. I like it. Problem is, it's not centering the...
2
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about...
2
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I'm using an async page to kick off a couple of asynchronous web services using the PageAsyncTask class. I'm also testing a progress bar that uses an Ajax UpdatePanel and Timer control to...
5
by: =?Utf-8?B?SmFzb24gSGFydHNvZQ==?= | last post by:
I am writing an application in .net 3.5 (VB.net) using VS 2008. I am interacting with a stored procedure (MS SQL) and want to return status updates back to the user client side. I'm copying...
2
by: Greg Smith | last post by:
I have just installed vs2008. The ToolBox has a Ajax tab but only ScriptManager, ScriptManager Proxy, Timer, UpDatePanel and Update Progress are in there. How do I add all the toolkit controls?...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.