ResolveUrl without an ASP.NET Page

后端 未结 3 1114
-上瘾入骨i
-上瘾入骨i 2020-12-05 03:36

I am looking for a way to resolve a relative url the way you would with a page or control instance (MSDN Docs) such as:

Page.ResolveUrl(\"~/common/Error.aspx         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 04:15

    Use something like this - Controls is a folder name in your application and myController is the controller name. to create and instance and load the controller you can do it by:

    Controls_myController ctrl = Page.LoadControl(Page.ResolveUrl("controls/myController.ascx"));
    

    Hope this helps.

提交回复
热议问题