views:

11

answers:

3

Here is my code. I'm able to find Asp.net UserControl and play with attributes but I need to call specific method inside of it. Can anyone tell me how to do it?

var usercontrol = (UserControl)RadDockableObject1.FindControl("ControlName");
usercontrol.Visible = true;
usercontrol.MethodName();
A: 

Just cast it to your control type instead of UserControl f.e.

var myControl = (SpecificControlName)RadDockableObject1.FindControl("ControlName");
myControl.SpecificMethod();
ŁukaszW.pl
I was 21 seconds too slow... ;-)
consultutah
Is it should be UserControl ID?
Eugene
If you are asking about SpecificControlName then its name of a class. Your control has code behind, there is a class.. This is it's name. If it helps, please mark answer :)
ŁukaszW.pl
A: 

You need to cast it to the appropriate type. Right now you are casting it to UserControl. That will give you access to a set of properties and methods, but not all. Cast it to the particular type and you will have access to everything. Everything that is not-private that is...

consultutah
Can you show me an example please
Eugene
@Eugene, look at LukaszW.pl's answer.
consultutah
Do I need to cast based on UserControl ID?
Eugene
A: 

It's not working for me

Eugene
Show the code sample.
ŁukaszW.pl