If Your .NET application Uses Master Page then add the following line of code in the master page .By this you have to just call the function in the Master page.
<style type="text/css">
.normalfld
{
background-color: #FFFFFF;
}
.focusfld
{
background-color: #FFFFCC;
border-color:#33CCFF; color:Maroon ;
}
.HiddenColumn{display:none;
</style>
<script type="text/javascript">
function DoBlur(fld)
{
fld.className = 'normalfld';
}
function DoFocus(fld)
{
fld.className = 'focusfld';
fld.SkinID = "txtblue"
}
function DoBlur(fld)
{
fld.className = 'normalfld';
}
function DoFocus(fld)
{
fld.className = 'focusfld';
fld.SkinID = "txtblue"
}
</script>
protected void Page_Load(object sender, EventArgs e)
{
addBlurAtt(ContentPlaceHolder1);
}
private void addBlurAtt(Control cntrl)
{
if (cntrl.Controls.Count > 0)
{
foreach (Control childControl in cntrl.Controls)
{
addBlurAtt(childControl);
}
}
if (cntrl.GetType() == typeof(TextBox))
{
TextBox TempTextBox = (TextBox)cntrl;
TempTextBox.Attributes.Add("onfocus", "DoFocus(this);");
TempTextBox.Attributes.Add("onblur", "DoBlur(this);");
}
if (cntrl.GetType() == typeof(DropDownList))
{
DropDownList TempTextBox = (DropDownList)cntrl;
TempTextBox.Attributes.Add("onfocus", "DoFocus(this);");
TempTextBox.Attributes.Add("onblur", "DoBlur(this);");
}
}
This way you can expand the function for different controls of your application.