using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class controls_cookies_CookieConcent : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { if (Request.Params["__EVENTTARGET"] == upCookieConsent.UniqueID && Request.Params["__EVENTARGUMENT"] == "userAgreed") { container.Visible = false; //store this info per user //perform a check based on that stored data to know whether to show this control at all //if the user already agreed you can simply set the Visible property to false //postbacks on this same page while the viewstate is retained will work fine, but you should implement //a long term storage as well //you may also want to look into showing this only for users that need to see it (e.g., based on IP location) } } protected override void Render(HtmlTextWriter writer) { if (container.Visible) { Page.ClientScript.RegisterForEventValidation(upCookieConsent.UniqueID, "userAgreed"); } base.Render(writer); } }