
###前提・実現したいこと
Excelファイルやcsvをダウンロードさせる機能の実装がうまくできておりません。
ブラウジングで情報収集を試みましたが当方初心者のためサイトに書かれている内容が
今一つ理解できない状況です。
今試しているコードも怪しい理解です。
ファイルのダウンロードボタン実装方法についてご教授願えませんでしょうか。
###default.aspx
default.aspx
1 <asp:Button ID="ダウンロードボタン" runat="server" Text="OK" OnClick="func" />
###C#
C#
1 protected void func(object sender,EventArgs e) 2 { 3 string fileName = "C:\テストファイル.xlsx"; 4 string content = ????//このパラメータよくわからない 5 6Response.ContentType = "application/download"; 7 Response.ContentEncoding = System.Text.Encoding.GetEncoding("Shift_JIS"); 8 Response.AppendHeader("Content-Disposition", "Attachment; filename=" + HttpUtility.UrlEncode(fileName)); 9 Response.Write(content); 10 Response.End(); 11 }
###補足情報(言語/FW/ツール等のバージョンなど)
ASP webform(C#)
.netframework3.5



回答2件
あなたの回答
tips
プレビュー