嗯,下面显示了一种通过.cs使用jGrowl(在Shane’s Answer上扩展)的方法。
Webform ASP.NET中的此示例
使用1个按钮创建一个简单的aspx页面,并确保在页面头部包含必要的jquery /
jgrowl脚本和css引用,页面上也有一个scriptManager和update面板。
在页面后面的代码中:
protected void Button1_Click(object sender, EventArgs e){ this.ShowStatus("This is your message!<br />Some HTML formatting works!<br />");}protected void ShowStatus(string message){ scriptManager sm = scriptManager.GetCurrent(Page); if (sm.IsInAsyncPostBack) { string script = @" $(document).ready(function() { $.jGrowl.defaults.theme = 'iphone'; $.jGrowl('" + message + "', {theme: 'iphone',header: 'Notification',life: 8000});});"; scriptManager.RegisterStartupscript(Page,this.GetType(), "notification", script,true); }}自然使用适合您应用的主题,祝您好运!此外,该方法仅根据需要加载通知脚本(在这种情况下,单击按钮后),但是您可以将“ShowStatus”功能与后面代码中的其他事件/测试绑定。



