Server Web User Control or Web Custom Control

Ok, I made a DataGrid I like, stuck it in a Web Control Lib, and then to my toolbar.

Now I want to take my nice little control and add it to a greater control, maybe place some buttons around it etc.
I could always inherit from it in a new custom control and dynamically add the buttons, but I thought about using a Web User Control.
I thought I could easily create a Web User Control, drop on my grid and the buttons on a form, and expose some properties and events, but once I got into it, I got a feeling that this isn't what a Web User Control is for.
When designing a control like this (One that contains multiple controls), what should I be looking at? Custom Controls? Is there any way to have something like a form designer to do the layout with?
11/2/2003 9:03:39 PM
πŸ“ƒ 91979 articles.

πŸ’¬ 5 Replies
πŸ‘οΈβ€πŸ—¨οΈ 1259 Views

Some might disagree with me, but when I think of several controls I think of a Web User Control. For example, a login dialog is what I would consider a Web User Control.
11/3/2003 12:37:04 AM
But can a Web User Control have events?  I've noticed when I use one, It doesn't appear to work the same as a normal control.  I don't have a member variable for it, and the Control's properties don't seem to support events.
11/3/2003 7:15:30 AM
I have a Microsoft Press book OOP: Building Reusable Components with Visual Basic .NET.

The book's authors venture this about User Controls vs. Custom Server Controls:
"We'll cut to the chase right away and explain which control to use in one sentence: user controls are best when you create reusable user interface components for one specific application. Custom server controls are best for small and distinctive user interface options that can be used across many applications."
So, if your new control is destined for a known application framework (such as IBuySpy or DNN), then a User Control is probably more flexible. But, if it's more generic, and can be applied to any application, a Custom Server Control is probably the right way to go (since it makes no presumptions about the surrounding application framework).
By the way, you can raise and handle events in each type of control ...

11/3/2003 8:38:51 AM
That’s a good explanation on when to use and when not to.   This makes me wonder if I’m consuming the web user control incorrectly.

I tried to add it as a control to my toolbar but it won’t let me. But then I found out that I could just go into solution explorer and drag and drop the β€œFile” there, and it would produce the output. (No reference, and no handlers though) I tried doing the same thing with the class explorer.
Could someone tell me how I should put my Web user control on a form? Maybe this is my problem
11/3/2003 9:57:14 AM
I think I figured out what threw me for a loop.

"Visual Studio does not automatically add a declaration of user controls to the code"
After doing this manually and wiring up the events manually, everything else seemed to work just as I expected.
11/3/2003 11:28:27 AM