O
Omikron
Hi
I would like to set a property of an object (like Web UI control)
based on the property name to given value (as string.)
I have:
Dim obj_FinalProperty As System.Reflection.PropertyInfo =
obj_ref.GetType().GetProperty(PropertyName)
Dim obj_MethodInfo As MethodInfo =
obj_FinalProperty.GetSetMethod(True)
obj_MethodInfo.Invoke(obj_ref, Value)
obj_ref is the control reference. Now let's say I have a button and I
want to set its "Height" to "20" (provided as string). Height property
is System.Web.UI.WebControls.Unit, and I am getting exception when it
comes to Invoke call:
Object of type 'System.String' cannot be converted to type
'System.Web.UI.WebControls.Unit'. I don't know why this happens,
because when I write directly - button.Height = "20" everything is
fine. How can I overcome this problem ?
Many Thanks
Bartek
I would like to set a property of an object (like Web UI control)
based on the property name to given value (as string.)
I have:
Dim obj_FinalProperty As System.Reflection.PropertyInfo =
obj_ref.GetType().GetProperty(PropertyName)
Dim obj_MethodInfo As MethodInfo =
obj_FinalProperty.GetSetMethod(True)
obj_MethodInfo.Invoke(obj_ref, Value)
obj_ref is the control reference. Now let's say I have a button and I
want to set its "Height" to "20" (provided as string). Height property
is System.Web.UI.WebControls.Unit, and I am getting exception when it
comes to Invoke call:
Object of type 'System.String' cannot be converted to type
'System.Web.UI.WebControls.Unit'. I don't know why this happens,
because when I write directly - button.Height = "20" everything is
fine. How can I overcome this problem ?
Many Thanks
Bartek