Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to load usercontrol like this:
C#
 string root = "Managment/";
currentModule = "Word";
      
phMain.Controls.Clear();
UserControl UsrCtrl = (UserControl)Page.LoadControl(string.Format("{0}Module/{1}.ascx", root, currentModule));
UsrCtrl.ID = "report";
phMain.Controls.Add(UsrCtrl);


but get error:
C#
Cannot use a leading .. to exit above the top directory.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.
Posted

1 solution

See this article. It should help you:

click[^]
 
Share this answer
 
Comments
jiji2663 21-Nov-13 16:43pm    
when i'm put user control in manager folder it's work fine
but,when i'm put user control in folder Module gets error
Richard C Bishop 21-Nov-13 16:47pm    
In your String.Format segment, try this:

(UserControl)Page.LoadControl(string.Format("..Module/{0}.ascx",currentModule))
Sergey Alexandrovich Kryukov 21-Nov-13 20:48pm    
Sure, a 5.
—SA
Richard C Bishop 22-Nov-13 10:03am    
Thank you Sergey!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900