Tuesday, April 7, 2009

Google Anyltics Code for SearchEngine

Google Anyltics
******************************************

Copy the following code block into every webpage immediately before the tag. If a p age is dynamic, then you can use a common include (footer), just beore tag.





Google Anyltics Code for SearchEngine

Google Anyltics
******************************************

Copy the following code block into every webpage immediately before the tag. If a p age is dynamic, then you can use a common include (footer), just beore tag.


Code for Generationg Random No


//create a randam fakeid.....if exist,then only take it from database...


using system.Text

public string GetFakeID()
{
StringBuilder builder = new StringBuilder();

//take random size 4 with small letter
builder.Append(RandomString(4, true));

//take a random no between 1000 and 9999
builder.Append(RandomNumber(1000, 9999));

//take random size 4 with capital letter
builder.Append(RandomString(2, false));

string fakeid= builder.ToString();

if(CheckFakeidIsExist(fakeid))
{

return fakeid;

}
else
{
return GetFakeID();


}
}
//checking if id is exist

private bool CheckFakeidIsExist(string fakeid)
{
string sqlstr="select fkno from fakeiddetails where fakeid='"+fakeid+"'";
int fkno=objCon.SQLReturnInteger(sqlstr);
if(fkno>0)
{
return true;
}
else
{
return false;
}

}

private string RandomString(int size, bool lowerCase)
{
StringBuilder builder = new StringBuilder();
Random random = new Random();
char ch ;
for(int i=0; i
{
ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ;
builder.Append(ch);
}
if(lowerCase)
return builder.ToString().ToLower();
return builder.ToString();
}

private int RandomNumber(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}