propertyinfo.setvalue

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

This part is easy:
Dim oControl As Control

oControl = Me.Page.FindControl("TextBox1")

Dim oPropertyInfo As PropertyInfo

oPropertyInfo = oControl.GetType.GetProperty("Text")

oPropertyInfo.SetValue(oControl, "Some New Text", Nothing)

What about in the case when the property may have properties that need to be
changed?

For instance the Infragistics WebTextEdit control, I couldn't quickly find a
vb control example, has a property named "ButtonsAppearance" which has a
property named "CustomButtonToolTip". The following code produces a
targetexception.

oControl = Me.Page.FindControl("WebTextEdit1")

Dim oPropertyInfo As PropertyInfo

oPropertyInfo = oControl.GetType.GetProperty("ButtonsAppearance")

oPropertyInfo =
oPropertyInfo.PropertyType.GetProperty("CustomButtonTooltip")

oPropertyInfo.SetValue(oControl, "Some New Text", Nothing)

I don't believe oControl is the correct target here but am at a loss as to
how to provide the correct target. Any suggestions?
 
I wanted to pass on what I have found.

The ButtonsAppearance Property is READ ONLY. So is every other Property
whose Value is not a value type; I only perused Visual Studio and
Infragistics controls. Therefore it will not be possible to make changes to
these properties at runtime. If anyone resolves the TargetException, I'd be
interested in seeing the code.
 

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

Back
Top