views:

84

answers:

3

In a ASP.NET/JQuery/.NET 3.5 environment, how would I show a DIV with a "Don't show this message again" option when clicked will not show the DIV to the user.

I would need to do it in 2 different scenarios - 1 with authenticated users and the other with anonymous users.

A: 

Matt Berseth has a very informative post on how to do this for delete confirmation. However this solution will only work for authenticated users. For anonymous users you will probably have to do something client-side (a cookie?). I used his solution in my own application.

Matthew Jones
This requires me to use ASP.NET profiles. I'd rather not use it if its not necessary
DotnetDude
A: 

For authenticated users you could use a flag in the database and for anonymous users you could use a cookie.

Darin Dimitrov
+2  A: 

I used jquery cookie plugin to set a cookie and read it before i show the dialog

EXAMPLE: with a little bonus function

  if ($.cookie("warned") != "warned"){
    display_alert("WARNING: This diallog will not appear again until your next session");
    $.cookie('warned', 'warned', { expires: 0 }); 
  }

  function display_alert(message,title) {
    title = title || "Alert";
      $('#alert').text(message);

      $("#alert").dialog({
          autoOpen: false,
          bgiframe: true,
          modal: true,
        title:title,
          buttons: {
              OK: function() {
                  $(this).dialog('close');
              }
          }
      });
    $('#alert').dialog('option', 'title', title);
      $("#alert").dialog('open');
  }
mcgrailm
Do you have a code snippet for using JQuery cookie plugin?
DotnetDude