开发者

How to get a user control's type given its path

开发者 https://www.devze.com 2023-02-15 04:49 出处:网络
Is there a way to translate a path to a user control, ~/usercontrols/MyUser开发者_StackOverflow中文版Control.ascx, to a type, as in typeof(MyUserControl)?Use the LoadControl() method on the Page class

Is there a way to translate a path to a user control, ~/usercontrols/MyUser开发者_StackOverflow中文版Control.ascx, to a type, as in typeof(MyUserControl)?


Use the LoadControl() method on the Page class:

Loads a Control object from a file based on a specified virtual path. MSDN

LoadControl("MyUserControl.ascx").GetType()
0

精彩评论

暂无评论...
验证码 换一张
取 消