Hello! I'm having this problem (I need at the click of a button to save the file on the client side. The button is in editformsettings in Grid!
<asp:Button ID="ButSave" runat="server" Text="Save" CommandName="SaveAnket"/>
Grid event!
void Grid_ItemCommand (object sender, GridCommandEventArgs e)
{
if (e.CommandName == "SaveAnket")
{
SaveBlankOnClient ();
}
}
protected void SaveBlankOnClient ()
{
string filename = "TextFile.txt";
string longPath = MapPath (filename);
Response.ContentType = "APPLICATION / OCTET-STREAM";
string disHeader = "Attachment; Filename = \" "+ filename +" \ "";
Response.AppendHeader ("Content-Disposition", disHeader);
System.IO.FileInfo fileToDownload = new System.IO.FileInfo (longPath);
Response.Flush ();
Response.WriteFile (longPath);
Response.End ();
}
This operation does not work for me from the grid ... But in an ordinary button, it saves the file! I understand this is due to postback? How save file from the Grid? Help please)))
<asp:Button ID="ButSave" runat="server" Text="Save" CommandName="SaveAnket"/>
Grid event!
void Grid_ItemCommand (object sender, GridCommandEventArgs e)
{
if (e.CommandName == "SaveAnket")
{
SaveBlankOnClient ();
}
}
protected void SaveBlankOnClient ()
{
string filename = "TextFile.txt";
string longPath = MapPath (filename);
Response.ContentType = "APPLICATION / OCTET-STREAM";
string disHeader = "Attachment; Filename = \" "+ filename +" \ "";
Response.AppendHeader ("Content-Disposition", disHeader);
System.IO.FileInfo fileToDownload = new System.IO.FileInfo (longPath);
Response.Flush ();
Response.WriteFile (longPath);
Response.End ();
}
This operation does not work for me from the grid ... But in an ordinary button, it saves the file! I understand this is due to postback? How save file from the Grid? Help please)))