Calling Response to WriteFile and also update page problem

Hello,

I have a VB.net app the sends an Excel file to the browser and it also need 
to hide some fields on the form at the same time. But the form is not hiding 
the controlls. The "Open/Save/Cancel" diaolog opens on the browser but the 
page stays the same, the controls are not hidden. Below is a sample of the 
code I'm using to send the file to the browser and hide the controls. What 
am I doing wrong?

Sub SendReport(ByRef SaveFile As String)

    tblMessage.Visible = False

    lblMessage.Text = ""

    'Response.Flush()

    'Response.Close()

    'Response.ClearContent()

    'Response.ClearHeaders()

    Response.ContentType = "application/vnd.ms-excel"

    Response.WriteFile(SaveFile)

    Response.End()

    'Response.Flush()

    'Response.Close()

    Kill(SaveFile)

End Sub



Thanks,

John Wilhelm

johnwilhelm@charter.net




0
John
5/20/2010 2:28:40 PM
dotnet.framework.aspnet 1425 articles. 0 followers. Follow

1 Replies
660 Views

Similar Articles

[PageSpeed] 12

On May 20, 4:28=A0pm, "John" <johnwilh...@charter.net> wrote:
> Hello,
>
> I have a VB.net app the sends an Excel file to the browser and it also ne=
ed
> to hide some fields on the form at the same time. But the form is not hid=
ing
> the controlls. The "Open/Save/Cancel" diaolog opens on the browser but th=
e
> page stays the same, the controls are not hidden. Below is a sample of th=
e
> code I'm using to send the file to the browser and hide the controls. Wha=
t
> am I doing wrong?
>
> Sub SendReport(ByRef SaveFile As String)
>
> =A0 =A0 tblMessage.Visible =3D False
>
> =A0 =A0 lblMessage.Text =3D ""
>
> =A0 =A0 'Response.Flush()
>
> =A0 =A0 'Response.Close()
>
> =A0 =A0 'Response.ClearContent()
>
> =A0 =A0 'Response.ClearHeaders()
>
> =A0 =A0 Response.ContentType =3D "application/vnd.ms-excel"
>
> =A0 =A0 Response.WriteFile(SaveFile)
>
> =A0 =A0 Response.End()
>
> =A0 =A0 'Response.Flush()
>
> =A0 =A0 'Response.Close()
>
> =A0 =A0 Kill(SaveFile)
>
> End Sub
>
> Thanks,
>
> John Wilhelm
>
> johnwilh...@charter.net

Hi John,

after you set ContentType =3D "application/vnd.ms-excel" and call
Response.End you will not be able to "refresh" the page. That's
because you cannot combine text/html and application/vnd.ms-excel in
the same response. You can try to fix it by doing a small trick with
meta tag

instead of

Response.ContentType =3D "application/vnd.ms-excel"
Response.WriteFile(SaveFile)
Response.End()
Kill(SaveFile)

do

Dim meta As HtmlMeta =3D New HtmlMeta()
meta.HttpEquiv =3D "Refresh"
meta.Name =3D "keywords"
meta.Content =3D "0;URL=3D" & SaveFile <-- e.g. mydoc.xls
Me.Header.Controls.Add(meta)

Hope this helps
0
Alexey
5/21/2010 7:38:29 PM
Reply:

Similar Artilces:

FW: Install that critical update
--evnsjtxzoottzn Content-Type: multipart/related; boundary="mzvhjxlbuddj"; type="multipart/alternative" --mzvhjxlbuddj Content-Type: multipart/alternative; boundary="moiuthlqwnsfktrjo" --moiuthlqwnsfktrjo Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Customer this is the latest version of security update, the "November 2003, Cumulative Patch" update which fixes all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Instal...

After installing multiple updates, error code 0xC80001F
I have been installing multiple updates (due to computer restore). During this last set of updates, I noticed that there were a few that said they weren't installed (failed) successfully. I went back to the installed updates info, but there were no items that showed "failed". When I tried to go back to the Windows Update Home page, I received this error code [Error number: 0xC80001FE]. I do not have a 3rd party anti-virus or firewall active right now. I have done nothing following the installation of updates. -- Real integrity is doing the right thing, knowing tha...

Money unable to install update
I am running Microsoft Windows XP Home Edition 5.1.2600 Service Pack 3 Build 2600 I just purchased Microsoft Money Plus Deluxe and upgraded from Money 2005 When I run MM Plus Deluxe, I receive a message "To Continue operating successfully, Money requires an update. Click OK to close Money and begin the update now." I press OK, Money closes and the update begins. I then receive a message that "Money was unable to install update." and to check my internet connection (which is always active and working) and have at least 100MB of disk space free (I have 24G free). I...

Rules Wizard: Auto Response
I want to use the rules wizard to send a response automatically to all messages sent to me with the same subject. The problem is, Outlook 2004 will only do this for the first message each session, which is troublesome. (I do not have access to an Exchange server.) How can I configure Outlook 2004 to do this each time such a message is received? I am using a template to respond, but I would like to have the template automatically include the sender's message text, to include mail header (or whatever will show that the attachment they sent was received by me). How can I do this? ...

Trouble with a page break
Hi, I'm using the latest version of Office for Mac 10.6.3. I have a very simple spreadsheet, but somehow I bizarre page break got inserted that I wish to remove: http://screencast.com/t/NzlhNjBlODMt How do I do this? I wasn't able to eliminate it by right clicking on a cell and selecting, "Reset All Page Breaks". Thanks, - Dave If you were using Windows, I would say that it looks like a split window not a page break. In Windows that can be removed by double-clicking it. -- Jim Cone Portland, Oregon USA http://www.mediafire.com/PrimitiveSoftware .. .. .. "lare...

Problems with backup
Many of my clients were introduced to external hard drives for backup. Most of them have a common problem where sometimes the backup fails because quite randomly. Usually it's because for some reason it run much slower than normally and the person responsible for swapping the drives does their job and so the log says " x is not a valid drive". Now I'm suspecting that it has something to do with SQL Writer Service although I'm not sure how to prove it and the less how to fix it. SQL is running a couple of databases among others Monitoring and Panda anti virus. I h...

Call in?
Do new owners of Office X have to call up Microsoft to register their copy? If yes, what's the number? thanks. Ming <asdf@asdf.com> wrote: > Do new owners of Office X have to call up Microsoft to register their > copy? If yes, what's the number? thanks. Nope. We're not using Windoze :->>> This version does not require activation. Corentin -- - Mac:MS MVP (Francophone) - (MS) MVP: http://support.microsoft.com/default.aspx?ln=FR&scid=fh;FR;mvp Newsgroups produits MS: http://support.microsoft.com/newsgroups/?ln=FR ...

Repost
Please help. In an Access 2003 Asset database (based on Microsoft’s template) I have the following tables - tblAssets, tblAssetDescription, tblDepartments, tblEmployees, and tblAssetAssignment that contains the fields AssetAssignmentID (autonum,pk), AssetID (num,fk), DepartmentID (num,fk), EmployeeID (num,fk), AssignmentDate (date/time) and AssignmentDescription (txt). My forms are - frmAssetAssignment is a subform of frmAssets and records the history of the assignment of each asset by date, department and employee. These forms are working well. My problem is that I am having diffi...

Covered Call Options
Hello all, I do I go about dealing with a covered call transaction in Microsoft Money 2007 Premium? Currently what I am doing is inputing the option symbol, and choosing the transaction "Sell to Open" then when I go to expire the option I try to do a Sell to Close. However it does not seem to work? Also what happens if instead of expired I has the position assigned? how would I account for that? Thank you. Shhhh In microsoft.public.money, Shhhh wrote: > >I do I go about dealing with a covered call transaction in Microsoft >Money 2007 Premium? Currently what I am doing is...

property page with COM control inside .dll does not work!
Hi, all I am trying to make a MFC extension DLL in which there is a property page, and there is a COM control(Windows Media Player) in this property page. And I use this function in dll to create the property page: __declspec(dllexport) CPropertyPage* TE_newPage(); I call this function to create a property page in my .exe project and add it to my property sheet. I can compile this project with success but this property page does not work. The Application can run withou error messages, and the property page can be seen. But once you click the tab, it just disppears! And the Media Player COM...

NDR Problem #2
Hi All, I have a problem. In my installation of Exchange in SBS 2003 whe I use Outlook such as client everything is ok. If I use Outlook Express (or different client using standard SMTP) when I mistake the email address I do not receive the NDR from the server. Some suggestions? Thanks Bonato Pierantonio P.S. I use the same windows account for outlook and express Hi, by default exchange SMTP service is deliver a NDR, you can check under the SMTP Virtual Server or the routing group (Delivery Advanced), if something changed from the defaults you can see it over there. Cheers, N. -- ...

Word 2004 Graphics problems
I have noticed some problems with inserted graphics when opening word 2001 files with word 2004, the graphics appear to be of a much poorer quality than when viewed in 2001. Is there a way around this? ...

Java code to force update of a field on a lead form
I'm trying to create workflows that notify me when a user hasn't contacted a lead for more than 2 days. Currently I'm doing this by checking the condition of the Qualified status after waiting for two days, however this isn't ideal as the lead might not be in a position to be Qualified or Unqualified at that time. I've put a last updated field on the lead form that automatically generates the date and time when a lead is saved but I can't seem to create a workflow that says 'if the last updated date is greater than 2 days trigger an event'. I think I cou...

Template does not get updated when a project is closed
We have found a problem with the use of timesheet templates in the Business Portal. Apparently the template does not get updated when a project is closed or an employee's assignment to the project is removed. I would imagine there was no intention to do this given the nature of what a template is. However, we would like to raise an enhancement request to the Business Portal to see if something can be done to stop a timesheet being saved or submitted with a closed project code. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with t...

Money 2005 Updates
I converted Money 2004 files to 2005, then it ran some online updates and converted the money file to latest Money 2005 version. When I reinstalled Windows on my computer and installed Money 2005, it refused to open the file as it was in latest money format. I'ad to make a fake money file so that it can get the online updates from some Microsoft "magical" website. I wanna know, if I can download that Money 2005 update from somewhere so that I can install it offline after resintalling Money 2005? Thanks. That would be too easy. Therefore the Money team doesn't allow it...

Call center tracking and reporting
Anyone use CRM 4.0 for call tracking? Our Sales/Marketing is set up. Now I need to decide how to most efficiently customize CRM 4.0 for our company's call tracking portion. Can someone send me a link to information? thanks ...

Unwanted report page break
We have modified the sales order invoice "short form" extensively, using the modifier and vba. We are using multiple bands for each invoice line item, namely H2,H3,H4,H5,F5,F4,F3,F2 and F1. H3,H4,H5,F5,F4,F3,F2 are all conditional, so that the height needed to print each line item on the invoice is variable. The problem is that the invoice breaks on any one of the bands, so that it has a page break in the midst of a line item. Is there a way to prevent this? Can we force a page break at the start of a line item if it would otherwise break in the middle? Is there any way ...

No response after SMTP Data Command
Hello, We are running Exchange 2003 SP1 on Windows 2000 server. When we send external e-mail using SMTP, almost all of the hosts do not respond to the period at the end of the DATA. I am using Outlook 2003 as the client to send the e-mail. I also tried sending plain text, and that doesn't work. Again, there are very few sites that allow mail from our domain. Would anybody have any idea what the problem might be? Thanks in advance, cj Here is a trace from a packet sniffer: 220-hrndva-mx-04.mgw.rr.com ESMTP 220 Welcome to Road Runner. NO UCE *** FOR AUTHORIZED USE ONLY! *** HEL...

Intelligent Message filter update problem with Junk e-mail folder
I've recently installed Intelligent Message filter on my front end server. All appeared to be working OK, so I went ahead, updated the server with the IMF update and restarted the server. Inbound external messages are now assigned an SCL rating upon delivery on the front end server, but ALL messages seem to be being sent to the Outlook Junk e-mail Outlook folder when SCL rating is above that of 0 and 1. My delivery and junk e-mail settings are both set to 8 under Global Settings - Delivery, but messages are automatically being moved to Junk e-mail folder if they are greater tha...

telephone calls
when placing a telephone call using outlook, everything works fine except I can't hear the person i am talking to. They can hear me find. When I use a telephone program not associated with outlook every thing works great. can someone help ...

XML Document reference between asp.net pages
Hi all, I have just started working with XML documents. I have just built a form that creates an xml document and it sends it to biztalk where i get an xml document as a response. i read a node value from the xml document and depending on the result i open a new page. I was wondering what the best method is for referencing the response xml document created on the previous page??? i.e. should i save it or cache it or what ??? As i say im quite new to this so any help greatly appreciated. Regards CG ...

How to view all slides on 1 page in Publisher
How do I view all slides on 1 page so that I can put them in a particular order? Slides? Did you want the PowerPoint forum? David Bartosik - [MSFT MVP] www.publishermvps.com www.davidbartosik.com "Lisa's Ocean" <Lisa's Ocean@discussions.microsoft.com> wrote in message news:19D3D643-1D0F-4CE6-B56A-C5560452EA60@microsoft.com... > How do I view all slides on 1 page so that I can put them in a particular > order? Do you mean pictures? If so, just select the Insert menu, picture from file, get it, insert. After they are all on the page, move them around as yo...

Calling Macro
Hi All, I have macro like this sub unique() '''''''' '''''''' Counter_item = 0 For Each Item In nodups counter_item = counter_item + 1 bic_var = Item Call Ps_Match Next Item end sub I have another macro Sub Ps_Match() ''''' ''''' If counter_item <= 1 Then call another_macro() end if end sub In the first macro i am declaring counter_item equals to 1. In my second macro i need to call that number. At the to of the module put: Public Counter_I...

how do I put column headings on the second page of the table
my table went over to a second page and that is why I need to put the column headings again on the second page. How do I do that? Select the header row on the first page, click on Table dropdown menu and then click on "Heading Rows Repeat". Connie "officeuser" wrote: > my table went over to a second page and that is why I need to put the column > headings again on the second page. How do I do that? ...

Loop and Insert Problem
I have to move X number of records from one table to another table so this is a 2 part question. First I need to run the loop the number of times that TxtCount equals. Second I need to insert from the CheckDetails table to the Transfer table, however they have different fields. How can I do this? Any help appreciated. Thanks DS Me.TxtCount = Nz(DCount("CDItemID", "tblCheckDetails", "CDCheckID = " & Me.TxtLeftID), 0) Do Until Me.TxtCount Me.TxtTransferID = Nz(DMax("[TransferID]", "tblTransfers"), 0) + 1 CurrentDb.Execute "INSER...