こんにちは私は必要が生じた場合に通知をポップアップしたい。私は、新しいメッセージが到着したかどうかを調べるasp.netタイマーを使用しています。私が得ている問題は、jquery通知が表示されないということです。私はこれがアップデートパネルと関係があると推測しています。なぜなら、pageloadから呼び出そうとするとうまくいきました。ここに私のコードです。Jquery通知ポップアップ - jqueryとupdatepanels
protected void updateTimer_OnTick(object sender, EventArgs e)
{
Cache Cache = new Cache();
users = Cache.getUserDetailsByUserID(Convert.ToInt32(Page.User.Identity.Name));
if (users._bNewNotification)
{
List<UserNotification> listUserNotification = null;
listUserNotification = Cache.getLatestNotifcationsByUserID(Convert.ToInt32(Page.User.Identity.Name));
foreach (UserNotification userNotification in listUserNotification)
{
StringBuilder jquery2 = new StringBuilder();
jquery2.AppendLine("$.extend($.gritter.options, {");
jquery2.AppendLine("position: 'bottom-left',");
jquery2.AppendLine("fade_in_speed: 100,");
jquery2.AppendLine("fade_out_speed: 100,");
jquery2.AppendLine("time: 3000");
jquery2.AppendLine("});");
Page.ClientScript.RegisterStartupScript(typeof(Page), Guid.NewGuid().ToString(), jquery2.ToString(), true);
StringBuilder jquery1 = new StringBuilder();
jquery1.AppendLine(" var unique_id = $.gritter.add({");
jquery1.AppendLine(" title: 'This is a sticky notice!',");
jquery1.AppendLine(" text: '" + userNotification._NotificationType + "',");
jquery1.AppendLine(" image: 'http://s3.amazonaws.com/twitter_production/profile_images/132499022/myface_bigger.jpg',");
jquery1.AppendLine(" sticky: true,");
jquery1.AppendLine(" time: '',");
jquery1.AppendLine(" class_name: 'my-sticky-class'");
jquery1.AppendLine(" });");
Page.ClientScript.RegisterStartupScript(typeof(Page), Guid.NewGuid().ToString(), jquery1.ToString(), true);
}
users._bNewNotification = false;
users.UpdateNewNotification();
Cache.RemoveUserProfileCacheByUserID(users._USERS_ID);
}
}
は、誰かがあなたのアプローチは機能しません
Javascriptデバッガ/ブラウザコンソールでランタイムエラーをチェックしましたか? – foxy
はい発生したエラーはありません。私は関数がロードされているファイルに依存していることを知っているので、私は再びjavascriptファイルをリロードする必要がありますか? – pmillio