问题
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();
回答1:
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...
回答2:
Just cast it to your control type instead of UserControl f.e.
var myControl = (SpecificControlName)RadDockableObject1.FindControl("ControlName");
myControl.SpecificMethod();
来源:https://stackoverflow.com/questions/3355230/how-to-call-method-inside-of-usercontrol-which-is-nested-inside-of-raddockableob