Friday, January 22, 2010

JavaScript validateion for blank space

function CheckSpace(c)
{


var val=c;
var str;
for(var i=0;i<=val.length-1;i++)
{
if(val.charAt(i)==' ')
{
str=true;
}
else
{
str=false;
break;
}
}
return str
}

//Method to call this function

var val = document.getElementById('<%=txtDescription.ClientID %>').value;
if(CheckSpace(val))
{
alert('Space is not allowed');
return false;
}

Thursday, January 21, 2010

Sql query for select the rendom record in sqlserver

SELECT TOP 1 * FROM TBL_PERDETAILS ORDER BY NEWID()

//HERE NEWID() FUNCTION WILL GENRATE THE RENDOM ID

Tuesday, January 19, 2010

How to Get the value and text of a Dropdownlist using JavaScript

//Using this function you can get the value and text of dropdownList using JavaScript

function GetDropDornListValueAndText()
{
ddlReport = document.getElementById("<%=DropDownListReports.ClientID%>");
var Text = ddlReport.options[ddlReport.selectedIndex].text;
var Value = ddlReport.options[ddlReport.selectedIndex].value;

}