Hello everyone,
I'm fairly new to .NET though I come from a strong OOP background. Im having a little trouble with a simple user controll.
I have a page with a codebehind. In this codebehind there are 2 classes (both in the same namespace). First the class for the page itself then a class to handle dynamic generation of this user control based on a passed counter.
Here is the class:
public class TextBoxControls : System.Web.UI.Page
{
public int Draw(bool increment, int Counter, System.Web.UI.WebControls.PlaceHolder PlaceHolder1)
{
if (increment == true)
Counter++;
Control objControl = null;
for (int FormCounter = 0; FormCounter <= Counter; FormCounter++)
{
objControl = Page.LoadControl("ListEditBox.ascx");
PlaceHolder1.Controls.Add(objControl);
}
return Counter;
}
}
Ths user control ListEditBox.ascx is in the same directory as the code behind and the web form.
When trying to run this I get the following excpetion:
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: The virtual path '/ListEditBox.ascx' maps to another application, which is not allowed.
This happens on the line where I try to load the control.
Originally I had this code inside the main page class and it worked like a charm, for some reason when I moved it outside of the main page class and into its own class this error started happening.
If I pre-fix the path with the Application name like so:
<WEBAPPNAME>/ListEditBox.ascx
Then it works fine, obviously this is less than optimal as I would like the class and the page to be independant of any directory structure or application name.
Any ideas?
What am I missing?
I am a meat popsicle