building a server control using controlBuilder

Discussion in 'ASP .Net Building Controls' started by mr dropdown, Jan 8, 2006.

  1. mr dropdown

    mr dropdown Guest

    A very useful answer from Mike MacMillan a few days ago helped me create the
    server control I wanted. It is something like:
    <Main:Control>
    <Children>
    <Collection1 value=1></Collection1>
    <Collection1 value=2></Collection1>
    <Collection2 value=3></Collection1>
    <Collection2 value=4></Collection1>
    </Children>
    </Main:Control>

    I'm soing it by using several controlBuilders, one for each HTML tag type.
    The question is - how, in general, the cs file should look like? I mean, I
    have several classes, several control builders etc.
    First I wrote them 1 after the other in the root of the cs (inside the
    nameSpace) but then I realized that it's not very smart because when creating
    an instance of the control from a webForm page behind then after the name of
    the instance variable you can see in the intellisense all the class and all
    the controlBuilders! I tried to change the control builders "public" to
    "private" or "protected" but the compiler didn't like it. Then I just removed
    the word "public" and it worked fine - now I can't see the control builders
    from the code-behind intellisense. The question is - how should I do it?? I
    guess that answer won't be to remove the "public" from before the control
    builder declaration.
    Then I moved to the second problem - again in the interllisense, I could see
    the following options -Children, Collection1 , Collection2. It doesn't make
    sense. I wanted to see only children and then in the intellisense of children
    to see Collection1 and Collection2.

    My main question in here is - help. How should I arrange the server control
    class so it will show in the interllisense only the relevant options and only
    in the corrent location.

    Thanks
    mr dropdown, Jan 8, 2006
    #1
    1. Advertising

  2. mr dropdown

    mr dropdown Guest

    more questions

    1. for each tag that i'm using in the asp.net page I created a new class
    under the same namespace. I thought that since I'm going to have many
    different tags it make sense to use this method. The problem is that now when
    I'm adding the control to the asp.net toolbox, it adds a new item for each
    class that I created, instead of just puting there the main class. Any
    solution to this problem?
    2. In all the sub-classes I'm just getting the tags data, but I'm not using
    the Render method. Instead, I'm using only the Render method of the main
    class to get all the tags data. Is that a correct way to work?
    3. In the Render method - is there a special reason to work with:
    writer.WriteBeginTag("img");
    writer.WriteAttribute("src", src);
    writer.WriteAttribute("alt", alt);
    writer.Write(HtmlTextWriter.TagRightChar);
    writer.WriteEndTag("img");

    instead of the simple way:
    write.write("<img src=x alt=y bla bla bla>");

    Thanks!!


    "mr dropdown" wrote:

    > A very useful answer from Mike MacMillan a few days ago helped me create the
    > server control I wanted. It is something like:
    > <Main:Control>
    > <Children>
    > <Collection1 value=1></Collection1>
    > <Collection1 value=2></Collection1>
    > <Collection2 value=3></Collection1>
    > <Collection2 value=4></Collection1>
    > </Children>
    > </Main:Control>
    >
    > I'm soing it by using several controlBuilders, one for each HTML tag type.
    > The question is - how, in general, the cs file should look like? I mean, I
    > have several classes, several control builders etc.
    > First I wrote them 1 after the other in the root of the cs (inside the
    > nameSpace) but then I realized that it's not very smart because when creating
    > an instance of the control from a webForm page behind then after the name of
    > the instance variable you can see in the intellisense all the class and all
    > the controlBuilders! I tried to change the control builders "public" to
    > "private" or "protected" but the compiler didn't like it. Then I just removed
    > the word "public" and it worked fine - now I can't see the control builders
    > from the code-behind intellisense. The question is - how should I do it?? I
    > guess that answer won't be to remove the "public" from before the control
    > builder declaration.
    > Then I moved to the second problem - again in the interllisense, I could see
    > the following options -Children, Collection1 , Collection2. It doesn't make
    > sense. I wanted to see only children and then in the intellisense of children
    > to see Collection1 and Collection2.
    >
    > My main question in here is - help. How should I arrange the server control
    > class so it will show in the interllisense only the relevant options and only
    > in the corrent location.
    >
    > Thanks
    mr dropdown, Jan 8, 2006
    #2
    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. Chris Simeone

    Help needed with AddParsedSubObject() and ControlBuilder()

    Chris Simeone, Oct 29, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    125
    Chris Simeone
    Oct 29, 2004
  2. Jonathan Gauthier

    ASP.NET ControlBuilder with ITemplate

    Jonathan Gauthier, Nov 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    234
    Jonathan Gauthier
    Nov 10, 2004
  3. ITemplate and ControlBuilder

    , Mar 26, 2007, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    131
  4. Sky
    Replies:
    4
    Views:
    174
    Sky Sigal
    Jul 19, 2004
  5. Jonathan Gauthier

    ASP.NET ControlBuilder with ITemplate

    Jonathan Gauthier, Nov 10, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    214
    Jonathan Gauthier
    Nov 10, 2004
Loading...

Share This Page