Question

How can we create a banner which should see only one time when the user opens the web page at the very first time. After that it should be hidden. I am sorry, i don't know the exact name of this feature. It would be very grateful if somebody provides some new links for implementing this feature. I have appended the sample image with this post and you can see the specified portion in top of the image (Red Box).

Image Sample

Thanks in advance

Was it helpful?

Solution

There is no such feature in .net. You have to create your own implementation. the logic steps, from my point of view, the logic steps would be:

  1. Create DIV with your product recall in it
  2. Make the DIV invisible by default
  3. Check for the cookie
  4. If the cookie doesn't exist display the product recall and create the cookie with the session ID and date.
  5. If the cookie exist check if the current session ID and the one in the cookie matches
  6. If they don't match display the product recall and update the cookie with the session ID and date.
  7. If they match check if the difference between the current time and date and the cookie date is bigger that the value you want to control. if so, display the product recall and update the cookie with the session ID and date.

To create cookies

HttpCookie myCookie = new HttpCookie("UserSettings");
myCookie["Session"] = Session.SessionID;
myCookie.Expires = DateTime.Now.AddDays(1d);
Response.Cookies.Add(myCookie)

To read cookies

if (Request.Cookies["UserSettings"] != null)
{
    string userSettings;
    if (Request.Cookies["UserSettings"]["Session"] != null)
    { 
        userSettings = Request.Cookies["UserSettings"]["Session"]; 
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top