C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Using Cookies in Asp.NET


Posted Date: 16 Sep 2008    Resource Type: Code Snippets    Category: Validations

Posted By: anil momin       Member Level: Silver
Rating:     Points: 10




using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpCookie cookie = Request.Cookies["pref"];
if (cookie == null)
{
Label1.Text = "Un known Customer";
}
else
{
Label1.Text = "Welcome " + cookie["name"];

}
}
protected void Button1_Click(object sender, EventArgs e)
{
HttpCookie cookie = Request.Cookies["pref"];
if (cookie == null)
{
cookie = new HttpCookie("pref");
}
cookie["name"] = TextBox1.Text;
cookie.Expires = DateTime.Now.AddMonths(5);
Response.Cookies.Add(cookie);
Label1.Text = "New customer" + cookie["name"];
}
}


Attachments

  • Using Cookies in Asp.NET (21114-16128-cookies.rar)



  • Responses


    No responses found. Be the first to respond and make money from revenue sharing program.

    Feedbacks      
    Popular Tags   What are tags ?   Search Tags  
    Using Cookies In ASP.NET  .  

    Post Feedback


    This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
    You must Sign In to post a response.
    Next Resource: Noise Words
    Previous Resource: Check for whether atleast one Item of Grid is checked or not
    Return to Discussion Resource Index
    Post New Resource
    Category: Validations


    Post resources and earn money!
     
    Related Resources



    dotNet Slackers   BizTalk Adaptors    Web Design

    SPOC

    Contact Us    Privacy Policy    Terms Of Use