我如何在运行时
问题描述:
的文件复制到虚拟路径,我动态加载的用户控件像下面我如何在运行时
UserControl objUserControl = (UserControl)this.LoadControl("~/UserControls/ucProfileViewDefault.ascx");
现在我有一个位于其他位置的其他用户控件文件ucProfileViewSMSIS.ascx。我需要在运行时将此文件复制到我的虚拟路径,然后像下面那样加载它
UserControl objUserControl = (UserControl)this.LoadControl("~/UserControls/ucProfileViewSMSIS.ascx");
我该如何做?
答
Server.MapPath
和Page.ResloveUrl
会得到你的位置,那么你可以将它和负载:
var path = Server.MapPath(Page.ResolveUrl("~/UserControls/ucProfileViewSMSIS.ascx"));