How to get a user control's type given its path
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()
精彩评论