i trying display toastr message (info,error etc) after submitting form using button , update gridview control (which in update panel" in asp.net webform. thanks
you can using page.clientscript.registerstartupscript
method. example:
page.clientscript.registerstartupscript(this.gettype(), "toastr_message", "toastr.error('there error', 'error')", true);
but create method or extension method handle me:
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); }
use:
showtoastr(this.page, "hello world!", "hello");
if want little more robust, make type
parameter enum
.
Comments
Post a Comment