DevExpress ASP. NET export Excel automatically turns on Thunder problem, save as ASPX page by default

Source: Internet
Author: User

Currently taking the curve to salvation strategy:

Use MVC .....

<Dx:aspxgridviewID= "ASPxGridView1"runat= "Server"AutoGenerateColumns= "False"DataSourceID= "SqlDataSource1"Keyfieldname= "Friendlinkid"Theme= "Default"enabletheming= "True">                <Columns>                    <Dx:gridviewdatatextcolumnFieldName= "Friendlinkid"ReadOnly= "True"Visibleindex= "0">                        <editformsettingsVisible= "False" />                    </Dx:gridviewdatatextcolumn>                    <Dx:gridviewdatatextcolumnFieldName= "Linkname"Visibleindex= "1">                    </Dx:gridviewdatatextcolumn>                    <Dx:gridviewdatatextcolumnFieldName= "Linksrc"Visibleindex= "2">                    </Dx:gridviewdatatextcolumn>                    <Dx:gridviewdatatextcolumnFieldName= "Contact"Visibleindex= "3">                    </Dx:gridviewdatatextcolumn>                    <Dx:gridviewdatadatecolumnFieldName= "Publishdata"Visibleindex= "4">                    </Dx:gridviewdatadatecolumn>                </Columns>            </Dx:aspxgridview>            <Asp:sqldatasourceID= "SqlDataSource1"runat= "Server"ConnectionString= "<%$ connectionstrings:pengbg_dataconnectionstring%>"SelectCommand= "SELECT * FROM [Friendlink]"></Asp:sqldatasource>            <Dx:aspxgridviewexporterID= "ASPxGridViewExporter1"Gridviewid= "ASPxGridView1"runat= "Server"></Dx:aspxgridviewexporter>            <Asp:buttonID= "Button1"runat= "Server"Text= "button"OnClick= "Button1_Click" />

 protected voidButton1_Click (Objectsender, EventArgs e) {            varFileName =NewRandom (). Next ().            ToString (); varFullPath =@"C +"+ FileName +". xls"; using(varFS =NewFileStream (FullPath, FileMode.CreateNew, FileAccess.Write))            {Aspxgridviewexporter1.writexls (FS); } Response.Redirect ("default1?path="+FullPath); }
  Public classDefault1controller:controller {//        //GET:/default1/         PublicActionResult Index (stringpath) {String NewFileName= DateTime.Now.ToString ("YYYYMMDDHHMMSSFF"); returnFile (path), System.IO.File.ReadAllBytes"Application/vnd.ms-excel", Httputility.urlencode (string. Format ("{0}.xls", NewFileName))); }    }


Principle in speculation, debugging ...

DevExpress ASP. NET export Excel automatically turns on Thunder problem, save as ASPX page by default

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.