Retrieving all properties of control how to -asp.net

M

mpar16

hi,
could please help me to retrieve properties of a control, i got a
scenario to read all available properties and its current assigned
values for different controls in project. i tried with reflector tool
but it giving properties of classes. I am not sure how to get property
and its value. right now i have open property window for each control
(Properties window) and noting down from a-z properties and its values.
could you help me to get programmatically all properties and its value?
 
M

MikeS

Given a texbox and a button.

Imports System.Reflection
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dump(TextBox1)
End Sub
Private Sub Dump(ByVal o As Object)
Dim t As Type = o.GetType
For Each mi As MemberInfo In t.GetMembers
If mi.MemberType = MemberTypes.Property Then
Dim prop As Object = t.InvokeMember(mi.Name,
BindingFlags.GetProperty, Nothing, o, Nothing, Nothing)
Try
Response.Write(mi.Name & "=" & prop.ToString &
"<br>")
Catch ex As Exception
End Try
End If
Next
End Sub
End Class
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top