Sunday 15 June 2014

Implementing a download with SaveAs dialog box in ASP.Net -



Implementing a download with SaveAs dialog box in ASP.Net -

i trying show popup save file , user has take destination , alter file type if needs. read many articles still not getting clear thought of since new .net. code.when run code , click link buttons in grid view file downloaded without popup , without asking user's permission downloaded files must saved

protected void gridview1_rowcommand(object sender, gridviewcommandeventargs e) { if(e.commandname == "download") { response.clear(); response.contenttype = "application/octet-stream"; response.appendheader("content-disposition","attachment; filename=" + e.commandargument); response.transmitfile(server.mappath("~/uploadedfiles/") + e.commandargument); response.end(); } }

i need next achieved.

display saveas file dialog box

the type of file should automatically displayed in saveas dialog box.eg if type of file image in saveas dialog box .jpg should automatically displayed. have attached image of output here not clear concept.please help in advance

the savefiledialog windows forms control, doesn't work on website.

a browser display "what want file" dialog whenever server sends stream can't handle default - unfortunately, browsers can handle text streams, display them user.

but should going:

// clear response buffer: response.clear(); // set output plain text: response.contenttype = "application/octet-stream"; // send contents of textbox output stream: response.write(txtnewfile.text); // end response don't else sent (page piece of furniture etc): response.end();

asp.net

No comments:

Post a Comment