How to call method inside of usercontrol which is nested inside of RadDockableObject from content page?

笑着哭i 提交于 2020-03-02 08:59:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!