Path of a loaded UserControl (ascx)
-
Hi, i'm working on a template framework for .NET 1.1 that is to work pretty much like MasterPages in 2.0. It's almost done, but I decided to make templating also available for user controls, i.e. an ascx control could be templated. But when working on it, I stumbled upon a little problem that I havent found any good solution to yet. The problem is that a user control dont have any property for it's virtual path. Like when i use an ascx file in a page (/control/mycontrol.ascx), i would like it's class to be aware of it's path. I havent been able to find any property that hold that value. The closest thing I found was the property
Control.TemplateSourceDirectory
and because ascx files derive fromUserControl
that in turn derives fromTemplateControl
, the value ofTemplateSoureDirectory
will be the directory holding the ascx file. But that wont give me the filename of it. One possible solution I tought of is to use the name of the top classfilename_ascx
that is created when ASP.NET compiles the files. But it dont look like a consistent solution, so I wonder if anyone here has any better ideas about this? Propapbly some simple property or method I've missed as usual :doh: -
Hi, i'm working on a template framework for .NET 1.1 that is to work pretty much like MasterPages in 2.0. It's almost done, but I decided to make templating also available for user controls, i.e. an ascx control could be templated. But when working on it, I stumbled upon a little problem that I havent found any good solution to yet. The problem is that a user control dont have any property for it's virtual path. Like when i use an ascx file in a page (/control/mycontrol.ascx), i would like it's class to be aware of it's path. I havent been able to find any property that hold that value. The closest thing I found was the property
Control.TemplateSourceDirectory
and because ascx files derive fromUserControl
that in turn derives fromTemplateControl
, the value ofTemplateSoureDirectory
will be the directory holding the ascx file. But that wont give me the filename of it. One possible solution I tought of is to use the name of the top classfilename_ascx
that is created when ASP.NET compiles the files. But it dont look like a consistent solution, so I wonder if anyone here has any better ideas about this? Propapbly some simple property or method I've missed as usual :doh:I recently had the same problem and to amke matters worst the client's ISP did not allow you to create virtual directpries! The ONLY solution that seemed to work waws to place ALL of the user control into the application's root directory instead oof into a subdirectory called "controls"... The controls were placed always at the same level or in directories BELOW the one the aspx files were in and this solved the problem. Bill SerGio