ボタンを使用してフォームを送信した後、toastr メッセージ (情報、エラーなど) を表示し、asp.net webform の gridview コントロール (更新パネルにあります) を更新しようとしています。ありがとう
14646 次
2 に答える
13
Page.ClientScript.RegisterStartupScript
メソッドを使用してそれを行うことができます。例:
Page.ClientScript.RegisterStartupScript(this.GetType(),
"toastr_message", "toastr.error('There was an error', 'Error')", true);
しかし、私はおそらくそれを処理するためのメソッドまたは拡張メソッドを作成します:
public static void ShowToastr(this Page page, string message, string title, string type = "info")
{
page.ClientScript.RegisterStartupScript(page.GetType(), "toastr_message",
String.Format("toastr.{0}('{1}', '{2}');", type.ToLower(), message, title), addScriptTags: true);
}
使用する:
ShowToastr(this.Page, "Hello world!", "Hello");
もう少し堅牢なものが必要な場合は、type
パラメーターを。にすることができますenum
。
于 2013-03-21T13:31:49.577 に答える