Navigation Bar

Wednesday, September 2, 2009

Clear Transaction Log

DUMP TRANSACTION [database_name] WITH NO_LOG

Tuesday, August 4, 2009

Remove Space In JavaScript

function RemoveSpaces(ctrlId) {
val = document.getElementById(ctrlId).value;
document.getElementById(ctrlId).value = val.split(' ').join('');
}

onblur="RemoveSpaces(this);"

Get Ramdom Password

public enum PasswordType { Pass, Specified, Random };
private enum NameField { Separate, Union };
private const string ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
private const string NUMBER = "0123456789";
private const string SYMBOL = "!\"#$%&'()-=^~\\|[{@`]}:*;+_/?.>,<";


private static string GenRandomPassword()
{
StringBuilder ret = new StringBuilder();
Random rnd = new Random();
while (true)
{
ret = new StringBuilder();
bool haveAlpha = false;
bool haveNumber = false;
bool haveSymbol = false;
for (int i = 0; i < 10; i++)
{
int t = rnd.Next(3);
if (t == 0)
{
haveAlpha = true;
ret.Append(ALPHABET[rnd.Next(ALPHABET.Length)]);
}
else if (t == 1)
{
haveNumber = true;
ret.Append(NUMBER[rnd.Next(NUMBER.Length)]);
}
else
{
haveSymbol = true;
ret.Append(SYMBOL[rnd.Next(SYMBOL.Length)]);
}
}
if (haveAlpha && haveNumber && haveSymbol) { break; }
}
return ret.ToString();
}


// To check Invalid Password
if
(specPassword.IndexOfAny(NUMBER.ToCharArray()) == -1 || specPassword.IndexOfAny(SYMBOL.ToCharArray()) == -1)
{
throw new Exception("Invalid password ( password should contain at least one number and symbol )");
}

Friday, July 31, 2009

Disable back button in browser

function noBack() {
window.history.forward();
}
in body tag add the following

onpageshow="if(event.persisted)noBack();" onload="noBack();"

Go to First Page of the browser

function GoFirstPage() {
var Backlen = history.length;
history.go(-Backlen);
//window.location.href = '';
}

Shutdown XP automatically

Click Start, Run and type control schedtasks
Double-click Add Scheduled Task. The Scheduled Task Wizard starts.
Click Next.

Under Click the program you want Windows to run, click Browse.

In the Select Program to Schedule dialog box, locate the %SystemRoot%\System32 folder, locate and click the Shutdown.exe file, and then click Open.

Under Perform this task, specify a name for the task and how frequently you want this task to run, and then click Next.

Under Select the time and day you want this task to start, specify a start time and date for the task, and then click Next.

Type the user name and password to run this task under, and then click Next.

Click to select the Open advanced properties for this task when I click Finish check box, and then click Finish.

Click the Task tab. In the Run box, specify any additional parameters that you want to use with Shutdown.exe. Click OK.

Important: In the 10th step, you need to add the parameters for the Shutdown.exe command. To immediately shutdown the system (0 second timeout), the command-line would be:

shutdown.exe -s -t 00

To reboot the system immediately, this command:

shutdown.exe -r -t 00

Monday, July 27, 2009

Javascript for number only

function CheckDateEntry(e)
{

var e = event || evt;
var keyval = e.which || e.keyCode;

alert(keyval);
if((keyval>=48 && keyval <=57) || (keyval==111 || keyval==191 || keyval==8 || keyval==46 || keyval==37 || keyval==39 || keyval==35 || keyval==36 || keyval==47))
{
return true;
}
else
{
return false;
}
}

Thursday, July 23, 2009

Split and String to Array

public object[] StringToArray(string input, string separator, Type type)
{
string[] stringList = input.Split(separator.ToCharArray(),StringSplitOptions.RemoveEmptyEntries);
object[] list = new object[stringList.Length];

for (int i = 0; i < stringList.Length; i++)
{
list[i] = Convert.ChangeType(stringList[i], type);
}

return list;
}