Javascript - Response Object Not Returning Excel Stream In Update Panel?

Oct 11, 2010

I am generating an Excel file upon a click of a button in an update panel. It is throwing a parsing error.

If I keep the button outside the update panel it is working fine. Why isn't it working in the update Panel?

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition",
String.Format("attachment;filename={0}", filename))
Response.Clear()
Response.BinaryWrite(WriteToStream.GetBuffer)
HttpContext.Current.ApplicationInstance.CompleteRequest()
Private Function WriteToStream() As MemoryStream
'Write the stream data of workbook to the root directory
Dim file As MemoryStream = New MemoryStream
hssfworkbook.Write(file)
Return file
End Function

View 1 Replies


Similar Messages:

Architecture :: How To Handle An Excel Stream And The Http Response

Jan 27, 2011

I'm using .net 3.5 and am currently creating a web application used to generate a report through Aspose.CellsActually, the page is composed in a form where I get the configuration of the report I have to generate. The "generation" button is in an update panel. When I click on it, the "generation" button is hidden and a progress bar appears. When the excel file is generated, I save it in a memory stream and I send it back to the aspx page where I change the headers to allow the file's download.

View 3 Replies

Update Image Based On Response Stream?

Sep 20, 2010

Is is possible to update an image on an HTML page using the response stream of an ASP.NET Generic Handler? For example, if I have the following code on a handler: [URL]

public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "image/png";
context.Response.WriteFile("~/images/test.png");
}

How can I call the handler in jQuery, using .ajax, and set an image on the page equal to the image that is returned by the Handler? I am ignoring the query string variable at the moment as I just want to get this working. Secondly, if I can do above, how can I loop through all of DIVs on the page that are of class "content", select a guid out of a hidden field to use as my query string parameter, and update the associated image within the same content DIV tag? A content div tag would look as follows:

<div class="content">
<asp:TextBox runat="server" Id="HiddenField_1" Value="C142E68F-B118-4565-9A9E-B2347F0B6D5B"/>
<img src="#"/>
</div>
<div class="content">
<asp:TextBox runat="server" Id="HiddenField_2" Value="GJ38AD23-B118-4565-9A9E-B2347F0B6D5B"/>
<img src="#"/>
</div>

I would like to have all the images updated on a periodic interval, so essentially, as a quick recap, I would need to have: A loop through all of my DIVs of class "content", occuring every n. seconds. Extractation the GUID from the hidden field. A call to my ASHX handler to get the updated image. Set the returned image to the corrisponding image on the page. Is this something that would be difficult to achieve? If not, what would I need to do to make this function in the above manner?

View 1 Replies

Save A File / Stream To Local Folder From Response Output Stream?

Feb 22, 2011

I have an excel file in my Response Output stream. I can Open the stream as a file after a prompt, but it doesn't seem I can save it directly to a specified folder on my client.

View 1 Replies

AJAX :: Update The Chart Using An Update Panel And Timer In Javascript

May 17, 2010

i am attempting to use javascript to update the chart, because how i have setup now causes the chart to just disappear. Here is the code i have now: I am calling the chart to page using: on default.aspx

[Code]....

Code on the dataURL_Infrasturcture_Capacity.aspx page:

[Code]....

PROBLEM: So how would i update this using an update panel and timer. Currently when i do it the chart just disappears on update. I believethis is due to the fact that i am calling a dataURL. How would i get this to work javascript?

View 2 Replies

AJAX :: Update Panel Running JavaScript Fails On Update?

Aug 6, 2010

I have the following function that is trigered from an asp dropdownlist when an item is selected.

[code]....

The script sets a url depending on the selection from the dropdownlist.

It all works ok, but then the update panel updates and the javascript photogallary breaks.

How do I prevent this from happening.

View 17 Replies

AJAX :: Fire JavaScript After Update Panel Update?

Mar 2, 2011

i have update panel which has button inside

so when i click button, the update panel refreshed auto.

the problem is i want to fire java script when i press the button

[Code]....

View 6 Replies

Forms Data Controls :: Export Gridview To Excel Using Update Panel?

Mar 19, 2010

I have this code below. I can't export gridview to excel when using Update Panel.

[Code]....

My Code in exporting Gridview to excel

[Code]....

View 1 Replies

C# - Return XML To The Response Stream?

Nov 10, 2010

I'm trying to return an xml string from a IHttpHandler to a like this: context.Response.Write(xml); When I receive the response in my .aspx.cs I try to load the document as follows: var xml = XDocument.Load(xmlString); but I get an Illegal Characters in Path error message. I've also tried

context.Response.Write(context.Server.HtmlEncode(xml));

and

var xml = XDocument.Load(Server.HtmlDecode(xmlString));

but I get the same message. Is there any way I can return XML from my IHttpHandler?

View 3 Replies

AJAX :: Export To Excel Button Does Not Work Inside Update Panel Control

Mar 15, 2013

i have gridview and export to excel button inside Update panel, the code i am using to export gridview data to excel is..

public void imgExcelExport_Click(object sender, ImageClickEventArgs e)
{
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.xls"));
Response.ContentType = "application/ms-excel";

[code]...

View 1 Replies

C# - Convert Response Stream To An Image?

Aug 29, 2010

in previously asked question answeres said they dont get what i want to do exactly so heres is the full code also i simply want that instead of a TABLESe i rendered an image( of the content ) on the page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Text;
using System.Data;
using System.Drawing;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Web.UI.WebControls.Panel panelmain = new System.Web.UI.WebControls.Panel();
System.Web.UI.WebControls.Literal abc = new System.Web.UI.WebControls.Literal();
abc.Text = "as<br/>dasdas<br/>dasdad";
DataSet ds = new DataSet();
DataTable dt;
DataRow dr;
DataColumn idCoulumn;
DataColumn nameCoulumn;
dt = new DataTable();
idCoulumn = new DataColumn("ID", Type.GetType("System.Int32"));
nameCoulumn = new DataColumn("Name", Type.GetType("System.String"));
dt.Columns.Add(idCoulumn);
dt.Columns.Add(nameCoulumn);
dr = dt.NewRow();
dr["ID"] = 1;
dr["Name"] = "Name1";
dt.Rows.Add(dr);
dr = dt.NewRow();
dr["ID"] = 2;.............

View 1 Replies

C# - Render Response Stream With Jquery?

Jan 9, 2010

MemoryStream export = new MemoryStream();
iCalendarSerializer serializer = new iCalendarSerializer(iCal);
serializer.Serialize(export,System.Text.Encoding.UTF8);
return export;

so I am using the C# DDay.iCal library for exporting my calendars. Serialize takes in a "stream" so I passed it a memory stream. I now have a generic handler that calls the method that contains the above code.

public class CalendarHandler : IHttpHandler
{
private Calendar service;
private Membership membershipS;
public void ProcessRequest(HttpContext context)
{
service = new Calendar ();
membershipS = new Membership (null);
string userName = context.User.Identity.Name;
Guid userId = membershipS.GetUsersId(userName);
context.Response.ContentType = "text/calendar";
// calls the export calendar(the code that showed above that uses dDay ical.
var t = service.ExportCalendar(userId);
t.WriteTo(context.Response.OutputStream);
}
public bool IsReusable
{
get
{
return false;
}
}
}

So now I wrote the icalendar to the Outputstream. Now I have a jquery post that goes to this method and now I am not sure how to take the OutputStream result that the jquery post will get and make it popup with a save dialog box.

$('#ExportCalendar').click(function(e)
{
$.post('../Models/CalendarHandler.ashx', null, function(r)
{
});
return false;
});

View 2 Replies

Insert Anywhere A String Into The Response Stream?

May 7, 2010

I created a simple Http Module that starts a timer on the PreRequestHandler and stops the timer on the PostRequestHandler to calculate the time it took the page to load. I then create some simple html and write my results to Response.Write. Since I'm doing this in the PostRequestHandler it's adding my results after the </html> tag. That's fine for testing but I need in a scenario where the page needs to validate.

I can't seem to figure out how I could manipulate the Response object to insert my results before the </body> tag. Response.Write and Response.Output.Write don't have that flexibility and I couldn't see a way to work with the Response as a string. Am I missing something easy?

View 1 Replies

C# - Create A BitmapDecoder Off .Net Response Stream?

Dec 6, 2010

We're getting this weird exception when trying to create a BitmapDecoder off an ASP.Net response stream. This is the line of code that throws the exception:

BitmapDecoder dec = BitmapDecoder.Create(
Request.Files[0].InputStream,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.OnLoad);

Here's some info on the file being uploaded: Filename: bank statement.jpg, Content length: 266041, Mime type: image/jpeg

This is the exception stack trace:

System.IO.IOException: Cannot read from the stream. --->
System.Runtime.InteropServices.COMException (0x88982F72):
Exception from HRESULT: 0x88982F72 [code]...

how we can prevent this from happening?

View 1 Replies

AJAX :: Cannot Select Object In Update Panel After A Number Of Async PostBacks

Jan 9, 2011

I am trying to create a simple web application that uses a barcode scanner to read the barcode and then insert the information into a database. I have been able to get the barcode scanner to read the barcode and place the information into a textbox.

Then using javascript when the enter key is triggered on the scanner it then clicks the button to do a AsyncPostBack on the updatepanel then using scriptManager.RegisterStartupScript I then focus on the text box and then select the text in it ready for a new barcode to be entered.

The problem that I am having is that I can get it to post back 26 times then it will go to error (with no information). If I then add additional controls to the page I can only get it to post back 10 times. Below is my code... I have been pulling my hair out for the last two days.

[Code]....

[Code]....

[Code]....

View 3 Replies

C# - Response.WriteFile - Write Out A Byte Stream

Sep 21, 2010

Is is possible to write to the http response stream from a dynamically created bitmap using the Response.Write/WriteFile without saving the image to the hard drive?

View 4 Replies

Injecting JavaScript Outside An Update Panel?

Jan 8, 2010

I have an aspx page with four UpdatePanels. Incidentally, each UpdatePanel corresponds to a JQuery UI tab. What I am trying to achieve is a JQuery UI modal dialog OUTSIDE the UpdatePanels that can be called from server-side code running INSIDE any of the UpdatePanels. So, inside the first UpdatePanel is an asp:Button which runs some server-side code. When an error ocurrs, I want to be able to inject some JavaScript that will call the modal dialog to display the error message. Here is the code I am using:

Dim script As String = "showPopupMessage('{0}');"
script = String.Format(script, errorMessage)
ScriptManager.RegisterStartupScript(Me.UpdatePanelBizInfo, Me.UpdatePanelBizInfo.GetType, Guid.NewGuid.ToString, script, True)

The showPopupMessage function on the page looks like this:

function showPopupMessage(msg) {
$('#<%=Me.LabelPopupMessage.ClientID %>').text(msg);
$('#dialogPopupMessage').dialog('open');
}

When the code runs to inject the JavaScript, nothing happens. I am assuming it has something to do with the fact that the error ocurrs in the code running inside an UpdatePanel. Upon inspecting the resulting HTML, the JavaScript is there. What am I doing wrong?

View 1 Replies

Examine WebResponse Without Affecting The Underlying Response Stream In .NET?

Oct 27, 2010

After a call to initial HttpWebResponse.GetResponseStream() and reading through the stream, that stream is done for and cannot be reused.

I have a situation where I need to examine the content of the response and if it is of a certain data, get another page and then pass the new response down the line. Otherwise, pass down the original response as is. The only problem is that after examining the response to check for this "special data", that response is no good to the downstream code.

The only way, I can think of, to make this transparent to the downstream code, is to create a derived class of HttpWebResponse, and somehow cache the data streamed, and pass that cached stream down the line instead of the initial stream. I'm not sure if that's even feasible since I haven't looked into it further.

View 3 Replies

MVC :: Unable To Remove The Cookie From The Response Stream After Reading It?

Sep 29, 2010

I am trying to use a custom ITempDataProvider provider to store TempData in a browser's cookie instead of session state. However, everything works fine except that I am unable to remove the cookie from the Response stream after reading it. The code exexutes fine but the cookie won't go away.

[Code]....

And in my controller:

[Code]....

View 6 Replies

Dynamic JavaScript Not Working In Update Panel?

Apr 20, 2010

I am working on an application where i have got, a content page within a Master Page. I have placed a gridview on the page. This gridview has three fields, one of them is TemplateFied, a BoundFiled and a CommandField, along with paging enabled in the gridview.

In the template field i am creating a dynamic javascript on RowDataBound.

I wanted to place this gridview in Update panel so that it doesnot re-loads when command is clicked or page is changed.

I placed a scriptmanager and an update panel, and placed the grid in it. Now my command field works only once and not more, and same is true for the javascript, it doesnt gets initilized.

View 6 Replies

AJAX :: JavaScript Is Not Working In Update Panel?

May 28, 2010

I have one asp.net content page and calling .js file in that content page <asp:ImageButton> onclient click event. but it is not all calling .js file

View 3 Replies

Javascript - Usercontrol Disappears When Using Update Panel?

Mar 3, 2011

I have a user control which acts as a footer for my website and uses java script jqdock.js to show apple type bottom menu. I added an update panel to the usercontrol. What problem I am having now is, it works fine initally but once I click the mail button which is in the usercontrol , the whole user control dissapears, after postback i guess. below is the usercontrol and code view:

enter code here


public void Page_Load(object sender, EventArgs e)
{

// Page.ClientScript.RegisterClientScriptInclude("bottomMenu", "../js/jqDock.js");
ScriptManager.RegisterClientScriptInclude(this,this.GetType(),"bottomMenu", "../js/jqDock.js");[code]....

View 1 Replies

Javascript - ASP Update Panel, Catching Exceptions?

Aug 28, 2010

Thisis the code I use to display an aspxloadingpanel with an ms update panel:

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(initializeRequest);
prm.add_pageLoaded(pageLoaded);[code]....

However when an error occurs on this page, the loading panel continuously remains on the screen...How can I catch errors so that instead it would actually show the error.

View 1 Replies

AJAX :: Javascript Lost In Update Panel?

Sep 24, 2010

i am using an update panel inside this i am using a jquery image upload which works fine outside an update panel, but when inside i think the javascript is not instalising. i have tried using RegisterClientScriptBlock without success.

the javascript is belo, because its a document.ready how can i make sure this is not lost in a update panel?

$(document).ready(function() {
/* example 1 */
var button = $('#button1'), interval;
new AjaxUpload(button, {

[Code]....

View 4 Replies

C# - How To Stop AJAX Update Taking Place In One Update Panel From Another Update Panel

Sep 5, 2010

We have two update panels on our webpage. Now first update panel is having button cancel. While second update panel is having a file upload control.

Now if the user uploads a file that is going to upload in about 2 mins, and in between, say after 30 seconds the user clicks the cancel button, the upload taking place in update panel 2 should stop.

How do we achieve this ?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved