Thursday, July 31, 2008

How To Clear All The Controls In Form

function clrCtrls()
{
with(document.forms[0])
{
for(var i=0; i < elements.length; i++)
{
var e = elements[i];
if(e.type == "checkbox" e.type == "radio" ){e.checked = false;}
if(e.type == "text" e.type == "hidden"){e.value = "";}
if(e.type == "select-one"){e.selectedIndex = 0;}
}
}
return false;
}

Call This Fuction From any Event = "return clrCtrls()";
IE/Firefox Supproted

Wednesday, July 30, 2008

Live web portal to get information on traffic status

A new web portal to get live information on traffic status, directions and auto fares for cities Bangalore, Hyderabad and Chennai. The traffic police have launched a live traffic portal (Transport Information System) where you can find


1. Optimal routes between any two places in the city...
2. Auto-fares
3. Bus routes and stops, etc.


Check ->


Delhi


Chennai


Chennai Live Traffic


Bangalore


Hyderabad


pune

Wednesday, July 23, 2008

How to Capitalize the First Letter (Title Case) of All Words in a string in C#


To Make our string as TitleCase use ToTitleCase method of TextInfo class in
System.Globalization namespace that does exactly what we need

CultureInfo.CurrentCulture.TextInfo.ToTitleCase("place your string here");
output : Place Your String Here

Monday, July 21, 2008

How To Use The Order By Clause When Using UNION ALL Clause

SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'CA' ORDER BY au_lname
union all
SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'UT' ORDER BY au_lname


Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'union'.


To Over Come Problem use derived tables, think of these as a self-contained table, a bit like a temporary table within the query

SELECT * FROM (SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'CA' ORDER BY au_lname) AS TEMP_COL_1
UNION ALL
SELECT * FROM (SELECT TOP 1000000000 au_id, au_lname, au_fname,state from authors where state = 'UT' ORDER BY au_lname) AS TEMP_COL_2,


when we want to use order by clause within the particular query then we need top else we will get the following error,
"
Msg 1033, Level 15, State 1, Line 1
The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.
Msg 1033, Level 15, State 1, Line 3
The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified."