Skip to content

Commit

Permalink
Improved the comment on the helper to describe how supporting correct…
Browse files Browse the repository at this point in the history
… order of notifications (When more than one call is made in the same page), and reverted some bit that is no longer needed in the code (minor refactor).
  • Loading branch information
Meligy committed Feb 4, 2012
1 parent b8cf437 commit 80a17d7
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions jQueryNotification/Helper/NotificationHelper.cs
Expand Up @@ -23,14 +23,13 @@ public static void ShowNotification(this Control control, NotificationType notif
// Allow adding multiple notifications by making the key unique
var scriptKey = Guid.NewGuid().ToString();

// Adding the call to the pre-render event of the page, so that multiple notification calls
// are added in the same order they are rendered in the page, not the order the calls are processed in page life cycle
control.PreRender += new EventHandler
((sender, e) =>
// Note that we need to use ScriptManager to be UpdatePanel friendly
// This will still work even if there is no ScriptManager on the page
// Also, changed from RegisterStartup so that the scripts are placed in the page
// in the order the controls that call them are rendered, not in the order they run in page lifecycle
// which is the same reason we are adding the call to pre-render event
ScriptManager.RegisterClientScriptBlock(control, control.GetType(), scriptKey,
ScriptManager.RegisterStartupScript(control, control.GetType(), scriptKey,
notificationScript,
// saves us from adding <script> in string and making it harder to re
addScriptTags: true));
Expand Down

0 comments on commit 80a17d7

Please sign in to comment.