building a server control using controlBuilder

M

mr dropdown

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
 
M

mr dropdown

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!!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top