私はDIV
要素を持っています:
<div runat="server" id="path">Nothing here... yet</div>
コンテンツを動的に変更する JavaScript。いくつかのアクションの後、私の要素は次のようになります (Firebug でテスト済み、JS は問題ありません)。
<div runat="server" id="path">FirstTest - SecondTest - ThirdTest</div>
<asp:Button runat="server"...
次に、テキスト ファイル ( )に保存します。
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
Button1.Click += new EventHandler(this.GreetingBtn_Click);
}
void GreetingBtn_Click(Object sender, EventArgs e)
{
HtmlGenericControl path = (HtmlGenericControl)Page.FindControl("path");
Response.AddHeader("content-disposition", "attachment;filename=download.txt");
Response.ContentType = "text/plain";
Response.Write(path.InnerText);
Response.Flush();
Response.Clear();
Response.End();
}
</script>
それも問題なく動作します (SaveDialog ポップアップ、ユーザーが場所を選択) が、... 出力ファイルには "Nothing here... yet" という 1 行しかありません。JavaScript による変更に反応しないようです。
DIV
常に最新のコンテンツを保存できるように、彼に強制的に更新させるにはどうすればよいですか?
助けてくれてありがとう!