Introduction
AJAX stands for Asynchronous JavaScript and XML. Working in ASP.Net with AJAX, developers can develop ASP.Net web applications more user friendly and fast enough to provide data with page postbacks. This programming methodology has removed old fashioned page refreshing method that throws the user back to the page top and lose the context where he was working before clicking the submit button to save data.
ASP.Net Postbacks
ASP.Net methodology based on client server data exchange works as all the data from the client end is sent to the web server then the web server processes the data and sends back to the client. It means AJAX has the ability to make asynchronous calls to a web server. AJAX sends only necessary data to the web server.
AJAX and ASP.Net Framework
ASP.Net framework considers AJAX as a client callback scripts. AJAX enables you to update the page content without posting the page back to the server. Basically AJAX uses XMLHttp ActiveX component or the XMLHttpRequest according to the client’s browser such as Internet Explorer or FireFox.
AJAX allows partial page postbacks that minimize the network usage by not sending the all form data to the server. This method enables the server to perform only limited actions on the data received coz the server does not need to process the whole page elements or images. There is no need to process the viewstate, images or all page elements to send back to the client while processing partial postbacks.
With AJAX there is no full page postback that maintains page location even when user clicks the submit button to perform some action on the page. Hence the use state is maintained and the user doesn’t need to scroll down to the location where he was working before clicking the submit button.
Sunday, May 04, 2008
AJAX GridView Databinding
C# code to Load the GridView using AJAX Asynchronous Postback
protected void bindGridView()
{
string connectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ToString();
SqlConnection sqlCon = new SqlConnection(connectionString);
try
{
SqlCommand sqlCmd = new SqlCommand("select * from categories", sqlCon);
sqlCmd.CommandType = CommandType.Text;
SqlDataAdapter sqlAdp = new SqlDataAdapter(sqlCmd);
DataSet myDataSet = new DataSet();
sqlAdp.Fill(myDataSet);
// Delay the current Thread to display
// the UpdateProgress status
// Not required in real projects
System.Threading.Thread.Sleep(4000);
GridView1.DataSource = myDataSet;
GridView1.DataBind();
}
catch(Exception ex)
{
lblErrorMsg.Text = ex.Message;
}
}
protected void btnLoadData_Click(object sender, EventArgs e)
{
bindGridView();
}
Sunday, April 27, 2008
salting in Password encryption using C#
Salting means :: creating random string and attach with original password before encrypting.So your password are safe and untraceble to dictionary attack.
public string MuruEncrypt(string paramPass)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string salt = Guid.NewGuid().ToString();
byte[] p = UnicodeEncoding.UTF8.GetBytes(text+salt);
byte[] en = md5.ComputeHash(p);
return Convert.ToBase64String(en);
}
public string MuruEncrypt(string paramPass)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
string salt = Guid.NewGuid().ToString();
byte[] p = UnicodeEncoding.UTF8.GetBytes(text+salt);
byte[] en = md5.ComputeHash(p);
return Convert.ToBase64String(en);
}
MD5 CryptoServiceProvider using C#
This class used to create a function Encrypt the Password.
Just put it this way,Whenever the user login into password protected pages of the website,their password first undergo the MD5 Algorithm based conversion.
Then converted or encrypted password check their identification on the stored data.
If both are matched,we allow the user to navigate the login protected pages.
This password can be crack down once the hacker using the dictionary attack if your database compromised by the hacker.
We can overcome this ,by using salting concept.
Salting means just before generating the hash of a text, we attach a piece of random string – known as a salt - into the original text.
using System;
using System.Data;
using System.Text;
using System.Configuration;
using System.Web;
using System.Security.Cryptography;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///
/// Summary description for Murugesan
///
public class Murugesan
{
public Murugesan()
{
}
public string MuruDate(DateTime d)
{
d = d.AddDays(2);
string DateAddS = d.ToLongDateString();
return DateAddS;
}
public string Encrypt(string text)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] p = UnicodeEncoding.UTF8.GetBytes(text);
byte[] en = md5.ComputeHash(p);
return Convert.ToBase64String(en);
}
}
Just put it this way,Whenever the user login into password protected pages of the website,their password first undergo the MD5 Algorithm based conversion.
Then converted or encrypted password check their identification on the stored data.
If both are matched,we allow the user to navigate the login protected pages.
This password can be crack down once the hacker using the dictionary attack if your database compromised by the hacker.
We can overcome this ,by using salting concept.
Salting means just before generating the hash of a text, we attach a piece of random string – known as a salt - into the original text.
using System;
using System.Data;
using System.Text;
using System.Configuration;
using System.Web;
using System.Security.Cryptography;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///
/// Summary description for Murugesan
///
public class Murugesan
{
public Murugesan()
{
}
public string MuruDate(DateTime d)
{
d = d.AddDays(2);
string DateAddS = d.ToLongDateString();
return DateAddS;
}
public string Encrypt(string text)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] p = UnicodeEncoding.UTF8.GetBytes(text);
byte[] en = md5.ComputeHash(p);
return Convert.ToBase64String(en);
}
}
Subscribe to:
Posts (Atom)