Getting Current Project Loaded

Discussion in 'ASP .Net Building Controls' started by Guest, Jul 17, 2004.

  1. Guest

    Guest Guest

    I am building an ASP.NET Custom Web Control and I am wondering if there
    is any standard method when implementing ControlDesigner for a Class to
    determine what directory the project that that the Web Page that the control
    has been embedded into is in while at Design Time.
    so that if MyControl is embedded in PJ.aspx - i would like to get the ~/
    folder for that current project that it is embedded in.


    I was hoping for something that ControlDesigner or something else would
    expose so that other Designers like (SharpDevelop/Delphi etc) would be able
    to provide their own information for this .
     
    Guest, Jul 17, 2004
    #1
    1. Advertising

  2. Guest

    [MSFT] Guest

    Hi John,

    Did you want to get the parent page's path? If so, you may try following
    string:

    this.Parent.Page.MapPath(".")

    Luke
     
    [MSFT], Jul 19, 2004
    #2
    1. Advertising

  3. Guest

    Guest

    I apologize if I did not use the word Design Time and Control Designer enough times in my original post.


    I am building an ASP.NET Custom Web Control and I am wondering if there is any standard method when
    _____________implementing ControlDesigner ______________
    for a Class to determine what directory the project that that the Web Page that the control has been embedded into is in while at
    _______________________Design Time____________________
    , so that if MyControl is embedded in PJ.aspx - i would like to get the ~/
    folder for that current project that it is embedded in.


    I was hoping for something that
    __________ControlDesigner ____________
    or something else would expose so that
    ________other Designers like (SharpDevelop/Delphi etc) _________
    would be able to provide their own information for this .



    "[MSFT]" wrote:

    > Hi John,
    >
    > Did you want to get the parent page's path? If so, you may try following
    > string:
    >
    > this.Parent.Page.MapPath(".")
    >
    > Luke
    >
    >
    >
     
    , Jul 19, 2004
    #3
  4. Guest

    [MSFT] Guest

    Hello,

    For ControlDesigner class, you may get the web control this designer is
    designing from its Component property. After get the IComponent, you can
    get it and its parent component's properties.

    Luke
     
    [MSFT], Jul 19, 2004
    #4
  5. Guest

    Guest

    I fail to see how that answers my original question of getting the project folder that the web control is embedded in.
    Xyz web control is going to know no more about the Project Directory then xyz's parent or xyz's parent's parent.

    "[MSFT]" wrote:

    > Hello,
    >
    > For ControlDesigner class, you may get the web control this designer is
    > designing from its Component property. After get the IComponent, you can
    > get it and its parent component's properties.
    >
    > Luke
    >
    >
     
    , Jul 19, 2004
    #5
  6. Guest

    Adam Barker Guest

    John,
    This code in your designer class obtains a DTE reference via IServiceContainer and some reflection. You can then access everything in the solution and its projects:

    // Acquire service container

    IServiceContainer objServiceContainer = (IServiceContainer)this.Component.Site.GetService(typeof(IServiceContainer));

    object objServiceContainerServices = objServiceContainer.GetType().InvokeMember("Services",

    BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.GetProperty,

    null,

    objServiceContainer,

    new object[] { }

    );

    // Create a type of CodeDomProvider

    Type domType = Type.GetType("System.CodeDom.Compiler.CodeDomProvider");

    object objCodeDomProvider = ((Hashtable)objServiceContainerServices)[domType];

    EnvDTE.ProjectItem objProjectItem = (EnvDTE.ProjectItem)objCodeDomProvider.GetType().InvokeMember("projectItem",

    BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.GetField,

    null,

    objCodeDomProvider,

    new object[] { }

    );

    // Create an EnvDTE.Project object

    EnvDTE.Project objProject = objProjectItem.ContainingProject;


    EnvDTE.Solution objSolution = objProject.DTE.Solution;
     
    Adam Barker, Jul 19, 2004
    #6
  7. Guest

    Guest

    Thank you.
    That seems to be what I needed hopefully. Now i just need to find out how well that works with other ASP.NET Desingers like the Web Matrix.



    "Adam Barker" wrote:

    > John,
    > This code in your designer class obtains a DTE reference via IServiceContainer and some reflection. You can then access everything in the solution and its projects:
    >
    > // Acquire service container
    >
    > IServiceContainer objServiceContainer = (IServiceContainer)this.Component.Site.GetService(typeof(IServiceContainer));
    >
    > object objServiceContainerServices = objServiceContainer.GetType().InvokeMember("Services",
    >
    > BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.GetProperty,
    >
    > null,
    >
    > objServiceContainer,
    >
    > new object[] { }
    >
    > );
    >
    > // Create a type of CodeDomProvider
    >
    > Type domType = Type.GetType("System.CodeDom.Compiler.CodeDomProvider");
    >
    > object objCodeDomProvider = ((Hashtable)objServiceContainerServices)[domType];
    >
    > EnvDTE.ProjectItem objProjectItem = (EnvDTE.ProjectItem)objCodeDomProvider.GetType().InvokeMember("projectItem",
    >
    > BindingFlags.Instance|BindingFlags.NonPublic|BindingFlags.GetField,
    >
    > null,
    >
    > objCodeDomProvider,
    >
    > new object[] { }
    >
    > );
    >
    > // Create an EnvDTE.Project object
    >
    > EnvDTE.Project objProject = objProjectItem.ContainingProject;
    >
    >
    > EnvDTE.Solution objSolution = objProject.DTE.Solution;
    >
    >
     
    , Jul 20, 2004
    #7
  8. On Mon, 19 Jul 2004 20:01:02 -0700,
    <> wrote:

    > Thank you.
    > That seems to be what I needed hopefully. Now i just need to find out how well that works with other ASP.NET Desingers like the Web Matrix.
    >


    I tried to make such component myself, you can check it out at :

    http://www.antoniob.com/projects/PDesignTimeTools.aspx

    it uses similar code as Adam Barker posted for VS.NET, but my component
    also works for Delphi.NET.

    I tried to do the same for WebMatrix but no success :(

    *PLEASE* mail me or post here if you find the way to get project folder in
    design time for WebMatrix.

    btw. PDesingTimeTools is free component with source code (Delphi.NET)



    --
    http://www.antoniob.com/
    remove antispam XremoveX from e-mail !
     
    Antonio Bakula, Jul 20, 2004
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo Birnbach [MS]
    Replies:
    0
    Views:
    3,363
    Marcelo Birnbach [MS]
    Jun 28, 2003
  2. Matt
    Replies:
    2
    Views:
    832
    Craig Deelsnyder
    Aug 16, 2004
  3. Udo Corban
    Replies:
    0
    Views:
    3,932
    Udo Corban
    Jan 23, 2004
  4. Alexandre Jaquet
    Replies:
    3
    Views:
    590
    Hendrik Maryns
    Nov 14, 2007
  5. Mike Dando

    SSL prevents project from being loaded.

    Mike Dando, Sep 11, 2003, in forum: ASP .Net Security
    Replies:
    3
    Views:
    144
    Mike Dando
    Sep 12, 2003
Loading...

Share This Page