Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Path of a loaded UserControl (ascx)

Path of a loaded UserControl (ascx)

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netwinformshelpquestion
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rouzbeh_d
    wrote on last edited by
    #1

    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 from UserControl that in turn derives from TemplateControl, the value of TemplateSoureDirectory 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 class filename_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:

    B 1 Reply Last reply
    0
    • R Rouzbeh_d

      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 from UserControl that in turn derives from TemplateControl, the value of TemplateSoureDirectory 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 class filename_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:

      B Offline
      B Offline
      Bill SerGio The Infomercial King
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups