We take pride in your success. We let our positivity drive us, day in and out. Talk to us at Mindfire to know us more.

Software Technology Tips

We have different methods to maintain the design standard (style for server controls) in a .NET application.
For instance,
We can do it by using Theme – by assigning the name of Theme File In each page or
We can once set it in Web.config file
We can also do it by applying css to every page.
 
If you are using Master Page in your application , the following method describes one more way of achieving this .
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.


Related Tags:

ASP.NET

Author: Monalisa Brahma

top

ASP.NET

Let us Connect!

privacy

copyright (c) Mindfire Solutions 2007-2012. Login