mercredi 30 janvier 2019

How to get changed class name of User Control from code behind C#

I created my own User Control with property CssClass that is connected with one of the TextBox inside my User Control and has some class as default.

After I build a page with this control, I add another class (with jQuery) to my user control.

What I want to achieve is to get all class names in code behind. Currently, I got only the default class name without an additional one. I do not have this issue with standard Web Control.

If anyone has an idea how to achieve that?

Code:

foreach (Control ctrl in all)
{
    // Some code
    UserControl usc = ctrl as UserControl;
    if (usc != null) {
        var classes = usc.GetType().GetProperty("[PROPERTYNAME]").GetValue(usc,null).ToString();
        //HERE I GOT ONLY DEFAULT CLASS NAME WITHOUT ADDITIONAL ONE I ADDED BY JQUERY
    }
}


* "all" is a ControlCollection of page.Controls






Aucun commentaire:

Enregistrer un commentaire