473,399 Members | 4,192 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,399 software developers and data experts.

ModalPopupExtender won't hide after Response.fush,respose.end()

Hi,

I have a modal popup with two radio-buttons as Excel and CSV and two buttons as download and cancel

On clicking download button i am doing the download functionality using response object.

I am trying to close the modal popup after downloading.using modalpopuExtender.hide()

But the modal popup is not hiding.

DESIGN:
Expand|Select|Wrap|Line Numbers
  1. <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" X="600" Y="250" TargetControlID="HiddenField1" PopupControlID="Panel1" 
  2.                      CancelControlID="btnCancel" >
  3.                     </cc1:ModalPopupExtender>
  4.                     <asp:HiddenField ID="HiddenField1" runat="server" />
  5.                     <asp:Panel ID="Panel1" runat="server" width="250px" height="150px" Style="display: none;">
  6.                         <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
  7.                             <ContentTemplate>
  8.                                 <table cellspacing="2" cellpadding="2" width="350px" height="100px" style="border:1px solid black;" bgcolor="#eeeeee" >
  9.                                     <tr>
  10.                                         <td align="right">
  11.                                             Select File Type:
  12.                                         </td>
  13.                                         <td >
  14.                                             <asp:RadioButtonList ID="rblFileType" runat="server" RepeatDirection="Horizontal">
  15.                                                 <asp:ListItem Text="Excel" Value="Excel"></asp:ListItem>
  16.                                                 <asp:ListItem Text="CSV" Value="CSV"></asp:ListItem>
  17.                                             </asp:RadioButtonList>
  18.                                         </td>
  19.  
  20.                                     </tr>
  21.                                     <tr>
  22.                                         <td align="right">
  23.  
  24.                                         </td>
  25.                                         <td align="left">
  26.                                             <asp:Button ID="btnDownload" runat="server" Text="Download"  CssClass="button" 
  27.                                                 onclick="btnDownload_Click" />
  28.                                             <asp:Button ID="btnCancel" runat="server" Text="Cancel" CssClass="button" 
  29.                                                 onclick="btnCancel_Click"/>
  30.                                         </td>
  31.                                     </tr>
  32.                                 </table>
  33.                             </ContentTemplate>
  34.                             <Triggers>
  35.                                 <asp:PostBackTrigger ControlID="btnDownload" />
  36.                             </Triggers> 
  37.                         </asp:UpdatePanel>
  38.                     </asp:Panel>
  39.                 </td>
  40.  
Code Behind:
Expand|Select|Wrap|Line Numbers
  1.  protected void btnDownload_Click(object sender, EventArgs e)
  2.     {
  3.  
  4.         if (rblFileType.Items[0].Selected == true)
  5.         {
  6.             Response.Clear();
  7.             Response.Charset = "";
  8.             Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
  9.             Response.AppendHeader("Content-Disposition", "attachment; filename=Organization.xlsx");
  10.             Response.TransmitFile(Server.MapPath("~/Upload_Files/Templates/Organization.xlsx"));
  11.             Response.Flush();
  12.             Response.End();
  13.         }
  14.         else
  15.         {
  16.             Response.Clear();
  17.             Response.Charset = "";
  18.             Response.ContentType = "csv";
  19.             Response.AppendHeader("Content-Disposition", "attachment; filename=Organization.csv");
  20.             Response.TransmitFile(Server.MapPath("~/Upload_Files/Templates/Organization.csv"));
  21.             Response.Flush();
  22.             Response.End();
  23.         }
  24.  
  25.         ModalPopupExtender1.Hide();
  26.         UpdatePanel1.Update();
  27.     }
  28.  
  29.  
Please let me know what is the problem with my code.

Thank you .

Chandramohan
Jan 18 '12 #1
1 4099
Frinavale
9,735 Expert Mod 8TB
I have a feeling that you're going to have to go about this a bit differently. I haven't been able to successfully retrieve a file the way you are attempting....

Move the logic for retrieving the file into it's own ASPX page. The purpose of the page is to simply retrieve what the user requests.

Add an IFrame to your page and when you click the btnDownload, call some JavaScript that sets the source of the IFrame to the URL of the ASPX page that retrieves the file.

If they hit cancel, then call some JavaScript that hides the popup.

-Frinny
Jan 18 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Anne | last post by:
hie there, i want to be able to pass multiple parameters to another page. currently, i am able to do so, but somehow i feel it is not the correct way to do it. below is part of what i have so far....
0
by: Shane | last post by:
Can someone tell me what the Response.StatusCode = "200" is doing below? I have another program that sends a stream of string data to the program below by using an HttpWebRequest. I want to use...
1
by: Dan | last post by:
Hi I've created a generic 'Report' class that takes a DataView from a DataGrid control and writes it out to the response as a csv file for download. Basically, when a user clicks the download...
10
by: Anthony Williams | last post by:
Hi gang, This one looks like a bug :o( As you may or may not know, setting session management in web.config to use cookieless sessions causes the ASP.NET runtime to munge a session ID into...
0
by: ECathell | last post by:
I am trying to debug a remote application that works fine on my devmachine(localhost) but does not work as intended on my production server. i have setup a codeblock that is supposed to show a...
10
by: Niggy | last post by:
I get an error - any help appreciated. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object...
0
by: jose.mendez22 | last post by:
I'm trying to fire a pop-up window before I execute a lengthy stored procedure so I may utilize this window as a status window on number of records executed. After my response.write statements...
4
by: Hexman | last post by:
Code below ---- I've asked a similar question on this forum earlier. This is a slightly different situation. Previous Question ---- I'm trying to save some specific web pages to disk as...
3
by: Simon Gare | last post by:
Hi All, having a problem with the error "Either BOF or EOF is True, or the current record has been deleted. " found a workaround that allows the non existent data to be bypassed and insert a 0...
0
by: musosmiffy | last post by:
Hi, I have been trying to get the following working for days - I wonder if anyone could help me? I am trying to list a set of database entries as a newspaper column. I am using classic ASP (not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.