Designer support question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JKJ

    Designer support question

    I have a custom web control that needs a javascript file
    to be included as part of the project. I want to have the
    control automatically add the file in a specific folder to
    the project when the control is added to the designer.
    I've been looking for some kind of designer class, but
    can't find anything that will enable me to do what I want
    to do. Can anybody point me in the right direction?

    Thanks!
  • allancto

    #2
    Designer support question

    this is a very reasonable request, but to my knowledge it
    hasn't been done yet because the location of a file in
    general is unknown.

    you might look at the DesignOnlyAttri bute documentation
    and prompt the user to locate the file if it's not yet
    part of the project. i'm not sure how you detect whether
    it already is, but that should be doable.

    while we're on the subject, perhaps a better way of doing
    that is to package the javascript file in an assembly
    with the control-- then it's sure to be there.

    [color=blue]
    >-----Original Message-----
    >I have a custom web control that needs a javascript file
    >to be included as part of the project. I want to have[/color]
    the[color=blue]
    >control automatically add the file in a specific folder[/color]
    to[color=blue]
    >the project when the control is added to the designer.
    >I've been looking for some kind of designer class, but
    >can't find anything that will enable me to do what I[/color]
    want[color=blue]
    >to do. Can anybody point me in the right direction?
    >
    >Thanks!
    >.
    >[/color]

    Comment

    • Dmitriy Lapshin [C# / .NET MVP]

      #3
      Re: Designer support question

      Hi,

      As far as I know, you can specify a designer for any control with the
      DesignerAttribu te class. What you can do is inheriting from a standard
      designer and overriding some methods to automatically add the JavaScript
      file. Please note that I am not sure this is 100% possible - it's just a
      direction to start digging towards.

      --
      Dmitriy Lapshin [C# / .NET MVP]
      X-Unity Test Studio

      Bring the power of unit testing to VS .NET IDE

      "JKJ" <myspambox@mchs i.com> wrote in message
      news:04a401c398 d4$f843fdc0$a10 1280a@phx.gbl.. .[color=blue]
      > I have a custom web control that needs a javascript file
      > to be included as part of the project. I want to have the
      > control automatically add the file in a specific folder to
      > the project when the control is added to the designer.
      > I've been looking for some kind of designer class, but
      > can't find anything that will enable me to do what I want
      > to do. Can anybody point me in the right direction?
      >
      > Thanks![/color]

      Comment

      • JKJ

        #4
        Designer support question

        I saw this in action via a control from Devmansion.com.
        You add a control to the webform and supporting files are
        automatically included in the project.

        The *.js file is part of the project, and included as
        contents. When the control is packaged, it will be in
        the root directory of the library. I can reference the
        file there.

        I have also embedded the script itself in a resource file
        and can read the contents of the .js into the .aspx at
        runtime, but this increases the size of the page by a few
        KB. I'd much rather have the control insert a <script>
        tag with a src attrib, than the entire script itself.

        I tried creating the file @ runtime and saving it in the
        folder in the application root. If the folder doesn't
        exist, then it creates that as well. If the file already
        exists, then no action is taken. If by chance it gets
        deleted, the control will detect that it is missing and
        recreate the js file.

        HOWEVER, to perform this action the ASP.NET worker
        process needs to have write permissions on the directory,
        and in the grand scheme of things, I think this could be
        percieved as security issue.
        [color=blue]
        >-----Original Message-----
        >I have a custom web control that needs a javascript file
        >to be included as part of the project. I want to have[/color]
        the[color=blue]
        >control automatically add the file in a specific folder[/color]
        to[color=blue]
        >the project when the control is added to the designer.
        >I've been looking for some kind of designer class, but
        >can't find anything that will enable me to do what I[/color]
        want[color=blue]
        >to do. Can anybody point me in the right direction?
        >
        >Thanks!
        >.
        >[/color]

        Comment

        Working...