I got a page written in c# and a webform written in HTML.

My goal is to show this html webform every time the default.aspx page get loaded ONLY when the cookie are already SET on the client browser. I will set/write the cookie through php from the webform so I assume the c# code just need to:

  1. READ THE COOKIE VALUE IF IS SET OT NOT,
  2. VISUALIZE OR NOT the html webform depending of the value cookie set.

Not sure if this must be done with c# in code behind or just in javascript.

So, is there any code in C# that allow me to call an HTML page and open it in the same page as a webform/pop-up? Also, is possible to trigger this html page in the way I can call it only if cookie are set?

public partial class Read : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
    if (Request.QueryString["cookie"] != null)
    {
        ReadCookie();
    }
}

protected void ReadCookie()
{
    //Get the cookie name the user entered
    String strCookieName = Request.QueryString["cookie"].ToString();

    //Grab the cookie
    HttpCookie cookie = Request.Cookies[strCookieName];

    //Check to make sure the cookie exists
    if (cookie == null)
    {
        lblCookie.Text = "Cookie not found. <br><hr>";   -> SHOW HTML-WEBFORM 
    }
    else
    {

-> DONT SHOW HTML-WEBFORM 
    }
}
}

Related posts

Recent Viewed