Posted by: NepaliCR7 November 10, 2016
ASP .Net - How to restore fields
Login in to Rate this Post:     0       ?        
add {} braces when checking for cookies is null or not. when you load you page at first the cookies are not set that's why you are gettin that exception.

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)

if (!(Request.Cookies["FirstName"] == null) && !(Request.Cookies["LastName"] == null))
{
TextBox1.Text = Request.Cookies["FirstName"].Value;
TextBox2.Text = Request.Cookies["LastName"].Value;
}
}
Read Full Discussion Thread for this article