Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referring to the object as this
Message
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Referring to the object as this
Versions des environnements
Environment:
C# 2.0
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01308809
Message ID:
01308809
Vues:
52
Hi everybody,

I wish I payed more attention to the recent thread about accessing object's name with this in C#.

I have the following code:
 protected void grdDeleteUsers_RowCreated(object sender, GridViewRowEventArgs e)
         {
             //Colors charts - see http://www.1netcentral.com/color-chart.html
             string onmouseoverStyle = "this.style.backgroundColor='00BFFF'"; // Deepskyblue

            string onmouseoutStyle = "this.style.backgroundColor='@BackColor'";

            string rowBackColor = String.Empty;

            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                if (e.Row.RowState == DataControlRowState.Alternate)

                    rowBackColor = System.Drawing.ColorTranslator.ToHtml(grdDeleteUsers.AlternatingRowStyle.BackColor).ToString();

                else rowBackColor = System.Drawing.ColorTranslator.ToHtml(grdDeleteUsers.RowStyle.BackColor).ToString();

                e.Row.Attributes.Add("onmouseover", onmouseoverStyle);

                e.Row.Attributes.Add("onmouseout", onmouseoutStyle.Replace("@BackColor", rowBackColor));

            }
        }
I want to make it generic, so I can easily add highligting to my grids. Note, that in my current implementation I specify grid's name.

Do you know how can I make this more generic - function in the page, method, etc.?

What would you suggest?

Thanks in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform