how to read value of style["display"] property of webcontrol using reflection

Pratik Gaikwad

I have some user controls and some web controls on my page. To read the Visibility property of the each control using reflection I wrote below line :

Object v;
if (control.GetType().GetProperty("Visible") != null)
     v = control.GetType().GetProperty("Visible").GetValue(control, null);

but how can I read the value of Style["display"] attribute of each control using reflection?

Thanks in advance.

hutchonoid

Here is a working example using a button for demonstration purposes only.

Style property with the attribute as a key we are looking for must be applied to it.

Markup:

<asp:Button ID="Button1" runat="server" Text="Button" Visible="false" style="display:block;" />

Code behind:

var styleProp = Button1.GetType().GetProperty("Style");
        if (styleProp != null)
            {
                var styleCollection = styleProp.GetValue(Button1, null) as CssStyleCollection;
                var value = styleCollection["display"];
            }

You would have to replace the button with which ever control you have already.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to set the value of a property to null using reflection

From Dev

Setting Property Value using Reflection

From Dev

How to get value of property from object of class at runtime using reflection

From Dev

How to get a property name and its value using Swift 2.0, and reflection?

From Dev

Property reflection - How to get value?

From Dev

Model Property Display Name using Reflection

From Java

How To Set Display Style Property Using React useState Hook

From Dev

How to click on a button using WebControl

From Java

Get property value from string using reflection

From Dev

Using Reflection.Emit to set a property value

From Dev

How to use reflection to get/set the value of a property?

From Dev

How to create a property on a dynamic object using reflection

From Dev

How can I Get the property by name from type and Set Propert value using reflection in C#

From Dev

get style property value using css()

From Dev

Initialize the Attributes property of a WebControl object using collection initializer

From Dev

Manipulate the Style Display property

From Dev

Parameter count mismatch when getting value of property using Reflection

From Dev

Is there any other approach to set a value to a Property (of an Instance) without using Reflection?

From Dev

Get protected property value of base class using reflection

From Dev

Parameter count mismatch when getting value of property using Reflection

From Dev

How to get class in the field value using reflection?

From Dev

How to obtain a field value using reflection?

From Dev

How to get the value of associate field using reflection

From Dev

How to cache web to read offline in webcontrol window phone

From Dev

Display the value of CSS property in HTML using JavaScript

From Dev

Uncaught TypeError: Cannot read property 'style' of undefined when using for loop

From Dev

Uncaught TypeError: Cannot read property 'style' of undefined when using for loop

From Dev

How to get the color property value defined in <style> tags using only Javascript?

From Dev

Set property of property of property using reflection

Related Related

  1. 1

    How to set the value of a property to null using reflection

  2. 2

    Setting Property Value using Reflection

  3. 3

    How to get value of property from object of class at runtime using reflection

  4. 4

    How to get a property name and its value using Swift 2.0, and reflection?

  5. 5

    Property reflection - How to get value?

  6. 6

    Model Property Display Name using Reflection

  7. 7

    How To Set Display Style Property Using React useState Hook

  8. 8

    How to click on a button using WebControl

  9. 9

    Get property value from string using reflection

  10. 10

    Using Reflection.Emit to set a property value

  11. 11

    How to use reflection to get/set the value of a property?

  12. 12

    How to create a property on a dynamic object using reflection

  13. 13

    How can I Get the property by name from type and Set Propert value using reflection in C#

  14. 14

    get style property value using css()

  15. 15

    Initialize the Attributes property of a WebControl object using collection initializer

  16. 16

    Manipulate the Style Display property

  17. 17

    Parameter count mismatch when getting value of property using Reflection

  18. 18

    Is there any other approach to set a value to a Property (of an Instance) without using Reflection?

  19. 19

    Get protected property value of base class using reflection

  20. 20

    Parameter count mismatch when getting value of property using Reflection

  21. 21

    How to get class in the field value using reflection?

  22. 22

    How to obtain a field value using reflection?

  23. 23

    How to get the value of associate field using reflection

  24. 24

    How to cache web to read offline in webcontrol window phone

  25. 25

    Display the value of CSS property in HTML using JavaScript

  26. 26

    Uncaught TypeError: Cannot read property 'style' of undefined when using for loop

  27. 27

    Uncaught TypeError: Cannot read property 'style' of undefined when using for loop

  28. 28

    How to get the color property value defined in <style> tags using only Javascript?

  29. 29

    Set property of property of property using reflection

HotTag

Archive