おそらく私が見逃した単純な見落としです(Response.Writeの内部動作がいくつかの状況で期待どおりに機能しないことについてのあいまいなブログ投稿を漠然と思い出しますが、これがそれらの1つであるかどうかは覚えていません):
状況は、SP2010 で実行されているコントロールにリンク ボタンがあり、HttpContext.Response.Write() を使用しない場合、すべてが期待どおりに機能します (つまり、ラベルの .Text 値を変更できます)。ただし、Context.Response.Write() を呼び出すと、コードをデバッグしてステップ実行できますが、何も起こらないように見えます (何も書き戻されず、他のコントロールへの変更は表示されません)。_layouts のアプリケーション ページで実行され、モーダル ダイアログに表示されます。
(基本的に、私はこれをやろうとしています - http://acveer.wordpress.com/2011/01/25/using-the-sharepoint-2010-modal-dialog/しかし、うまくいきません。編集:私がasp:Button に変更しても、まだ機能しません)
興味がある場合は、次のコードをご覧ください。
.aspx:
@ Page Language="C#" AutoEventWireup="true" ...
<asp:LinkButton CssClass="button remove" runat="server" OnClick="remove_Click" Text="Remove" ID="remove"></asp:LinkButton>
.aspx.cs:
public void remove_Click(object sender, EventArgs e)
{
....
//if successful
HttpContext context = HttpContext.Current;
if (HttpContext.Current.Request.QueryString["IsDlg"] != null)
{
testControl.Text = "test code";
//doesn't work, and prevents line above from working
Context.Response.Write("<script type='text/javascript'>alert('hi!');</script>");
Context.Response.Flush();
Context.Response.End();
// context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup()</script>");
// context.Response.Flush();
// context.Response.End();
}
}
似たようなものに出くわした人はいますか?
編集:役立つかもしれないいくつかの興味深い部分、
- ボタン自体は UpdatePanel 内にあります
- AsyncPostbackTrigger が割り当てられています