Accessing path in a custom designer

Discussion in 'ASP .Net Building Controls' started by Dale Preston, Apr 10, 2005.

  1. Dale Preston

    Dale Preston Guest

    I am creating a custom web control with a custom property editor. The
    custom editor is for setting a relative URL property of an item in a
    collection property of the control. Because the property is a collection,
    the UrlEditor will not work because of a known (even if not confessed) bug
    in all UITypeEditors that derive from UrlBuilder.

    How I can determine, within the EditValue method of my custom UITypeEditor,
    what the relative URL path of my project is, similarly to the way the
    UrlEditor does?

    Dale Preston
    MCAD, MCDBA, MCSE
    Dale Preston, Apr 10, 2005
    #1
    1. Advertising

  2. Dale Preston

    Guest

    I am unsure of the bug you are stating of but perhaps you could
    instantiate a UrlBuilder and merely use the UrlBuilder to get the
    relative url path. There is also the line thinking where you enumerate
    of the project members and then finding a project item that contains
    the information you need.
    , Apr 11, 2005
    #2
    1. Advertising

  3. Dale Preston

    Dale Preston Guest

    You're right, it may not be a bug, after all. Though I have read of several
    people having this same problem, and have never read where anyone has solved
    the problem, I am beginning to think that is is an expected behavior, under
    the circumstances. The scenario goes like this.

    I have the following three classes:

    MyControl : System.Web.UI.WebControls.WebControl
    MyChildObject
    and
    MyChildCollection : CollectionBase

    MyControl has a public property, ChildCollection, of type MyChildCollection
    which holds objects of type MyChildObject. MyChildObject has a public
    property, URL, which needs to hold a URL string that is preferably, but not
    necessarily, relative to the page that hosts MyControl.

    I place MyControl on the Page and when I select the control in the designer
    and then click the ChildCollection property I get a collection editor
    UITypeEditor as desired.

    The problem occurs when I try to use any UrlEditor (UrlEditor, XmlUrlEditor,
    XslUrlEditor) as the UITypeEditor for the URL property in the MyChildObject
    class. If, in the collection editor, I click to edit the URL property of
    the instance of MyChildObject, the desired result is to get a UrlEditor
    associated with the URL of my project. What I get, instead, is an error
    "Object reference not set to an instance of an object" with no clue given
    where the error is occuring or what object reference is not set.

    I have continued to work on the problem and think I am on the right track.
    The problem seems to be that the UrlEditor requires an IComponent or an
    ISite in order to associate the Page with the control. The first control is
    sited on the Page, and gets its ISite from the Page. The next level of
    control should get its ISite from the first control, which got it from the
    Page. If I understand correctly, the problem is that there is a break in
    the site lineage because the MyChildObject is in a collection rather than a
    direct descendent of MyControl..

    I now believe that the solution will have something to do with implementing
    IComponent and/or ISite in MyChildObject and somehow connecting that ISite
    back to the Page. Possible routes seem to be to implement one of, or some
    combination of, IContainer, ISite, and IComponent in MyControl or perhaps to
    implement one or more of them in my MyChildCollection.

    If there is anyone out there with more knowledge or understanding than I
    have about using ISite, IComponent, Control, and IContainer, I would
    appreciate any suggestions about how to get the Component from my Page to
    MyChildObject, or any other suggestions how to solve this dilemma.

    Regards,

    Dale Preston
    MCAD, MCDBA, MCSE


    "" <> wrote in message
    news:...
    > I am unsure of the bug you are stating of but perhaps you could
    > instantiate a UrlBuilder and merely use the UrlBuilder to get the
    > relative url path. There is also the line thinking where you enumerate
    > of the project members and then finding a project item that contains
    > the information you need.
    >
    Dale Preston, Apr 13, 2005
    #3
    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. Earl Teigrob
    Replies:
    0
    Views:
    383
    Earl Teigrob
    Oct 30, 2003
  2. Luminousc
    Replies:
    4
    Views:
    546
  3. Steve B.
    Replies:
    4
    Views:
    946
    Cheryl D Wise
    Jun 1, 2007
  4. Alexander Higgins
    Replies:
    3
    Views:
    1,063
    Teemu Keiski
    Jul 30, 2007
  5. Alexander Higgins
    Replies:
    0
    Views:
    435
    Alexander Higgins
    Jul 21, 2007
Loading...

Share This Page