Regarding double page loading

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TitusBarj
    New Member
    • Sep 2007
    • 1

    Regarding double page loading

    Hi all

    I have a problem I've been working at the few past days. I want to export a string in an excel format and in the meantime reload the page I'm at.

    The only thing I try do do is to disable the "Export" button when clicked because my export can take a long time. Once the export finished I'd want the button to return to enabled=true. The easier way to do it is to reload the page and there is my problem.

    Here's part of my code :

    <Page_load>
    BtnESearch.Attr ibutes.Add("OnC lick","_ctl0_Bt nESearch.value= '"
    + "Please Wait" +
    "';window.setTi meout('document .Form1._ctl0_Bt nESearch.disabl ed=true;',0)");


    <BtnESearch_Cli ck> // The Export Button
    try
    {
    string fileName = "Export_EXCEL.x ls";
    Response.Clear( );
    Response.Buffer Output = true;
    Response.Conten tType="applicat ion/vnd.ms-excel";
    Response.AddHea der("Content-Disposition","a ttachment; filename="+file Name);
    Response.Charse t = "";
    StringWriter wr = new StringWriter();
    Response.Write( v_convRateList. ExportExcel()); // The export
    Response.End();
    }
    catch
    {
    RaiseEvent ... // Reload the page
    }

    The problem is, if I reload my page after the export, this one display in excel. That's quite logic but I've not managed to avoid that.
    I've tried all sorts of ways to avoid it (changing Response attributes, prerender, javascript...) but the "Response.End() " seems to affect badly all my options and I couldn't avoid it.

    If someone have any idea, thanks in advance. I've been searching a long time on the Internet but only the Datagrid export seems to be used ^^
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    If the export is performing poorly, it may pay to try a different method:
    How To Query and Display Excel Data by Using ASP.NET, ADO.NET, and Visual Basic .NET

    Comment

    Working...