Tuesday, October 14, 2008
Cookies in Asp.net
A Cookie is a small text file that the browser creates and stores on the hard drive of your machine. Cookie is just one or more pieces of information stored as text strings. A Web server sends you a cookie and the browser stores it. The browser then returns the cookie to the server the next time the page is referenced. The most common use of a cookie is to store information about the user and preferences the user makes. For example, assume you like DVD's and register with Ebay to participate in online auctions.
Sql Databse Connection in asp.net
//This code create a sql connection and checks for the username and password
SqlConnection con = new SqlConnection(SqlDataSource1 .ConnectionString.ToString());
con.Open();
SqlDataAdapter ada = new SqlDataAdapter("Select * from login",con);
DataSet ds = new DataSet();
ada.Fill(ds,"login");
int len = ds.Tables[0].Rows.Count;
DataRow dr;
for (int i = 0; i < len; i++)
{
dr = ds.Tables[0].Rows[i];
if (s.Equals(dr[0].ToString()) && pass.Equals(dr[1].ToString()))
{
Response.Redirect("Home.aspx?user="+s);
}
}
Response.Redirect("Login.aspx");
con.Close();
SqlConnection con = new SqlConnection(SqlDataSource1 .ConnectionString.ToString());
con.Open();
SqlDataAdapter ada = new SqlDataAdapter("Select * from login",con);
DataSet ds = new DataSet();
ada.Fill(ds,"login");
int len = ds.Tables[0].Rows.Count;
DataRow dr;
for (int i = 0; i < len; i++)
{
dr = ds.Tables[0].Rows[i];
if (s.Equals(dr[0].ToString()) && pass.Equals(dr[1].ToString()))
{
Response.Redirect("Home.aspx?user="+s);
}
}
Response.Redirect("Login.aspx");
con.Close();
asp.net clear history in browser in asp.net
copy the following code in page load event of all pages.....
if(Request.Browser.Browser == "IE") Response.CacheControl = "No-Cache";else if(Request.Browser.Browser == "Firefox") Response.CacheControl = "No-Store";Response.Cache.SetCacheability(HttpCacheability.NoCache);
if(Request.Browser.Browser == "IE") Response.CacheControl = "No-Cache";else if(Request.Browser.Browser == "Firefox") Response.CacheControl = "No-Store";Response.Cache.SetCacheability(HttpCacheability.NoCache);
Subscribe to:
Posts (Atom)