Hello,
I have an application that is loading user controls, something like:
var w = LoadControl(this.WidgetInstance.Widget.url);
WidgetBodyPanel.Controls.Add(w);
I have a data table with my various url's that point to use controls in it.
The issue is that some of the user controls need additional parameters. I keep track of the type of user control in the data table ("ServicesWidget" for example), along with the additional parameters ("EndUserRegionId" for example).
But I need to cast the control to the correct type to be able to set the parameters.
If I were hardcoding it, it would look something like:
var w = (ServicesWidget)LoadControl(this.WidgetInstance.Widget.url);
w.EndUserRegionId = 1;
But, I do not know how to dynamically cast a user control.
Thank you for your help,
Sammer
I have an application that is loading user controls, something like:
var w = LoadControl(this.WidgetInstance.Widget.url);
WidgetBodyPanel.Controls.Add(w);
I have a data table with my various url's that point to use controls in it.
The issue is that some of the user controls need additional parameters. I keep track of the type of user control in the data table ("ServicesWidget" for example), along with the additional parameters ("EndUserRegionId" for example).
But I need to cast the control to the correct type to be able to set the parameters.
If I were hardcoding it, it would look something like:
var w = (ServicesWidget)LoadControl(this.WidgetInstance.Widget.url);
w.EndUserRegionId = 1;
But, I do not know how to dynamically cast a user control.
Thank you for your help,
Sammer