开发者

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()
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜