User Controls vs. Panels

G

Guest

I'm trying to determine if we want to use panels or user controls for our
pages. Our primary concern is performance, page loading and posting speed.

To illustrate my question, lets use the Customer Orders scenario:

Problem:
User needs to view orders and and edit, add, save on one page called
Orders.aspx. To begin with the page contains a grid with basic information
about an order. The user can click a row to edit or click an "Add" button to
add a new order.

When the user clicks edit or add some controls appear below the grid
allowing them to input data, and then save.

User Control Proposal:
We have the Orders.aspx page and two user controls. The user control with
the grid is called ucOrders.ascx and the user control allowing user input is
called ucChangeOrders.ascx.

The two user controls are on the page during design time, therefore they are
not loaded on the fly during runtime.

When the user clicks the edit button on the ucOrders.ascx control it raises
an event that the Orders.aspx page listens for and then passes the order id
to the ucChangeOrders.ascx page that populates its child controls with the
current data the user can change. When the user clicks save on the
ucChangeOrders.ascx control it raises an event that the Orders.aspx page
listens for to know a save has been done and react to it appropriately.

From a design perspective this approach allows the user controls to be
self-contained with the parent page acting as the controler. It is easier to
follow, the page is not bulky and easier to maintain. However, we fear a
performance hit for doing this will not justify doing it this way when
compared to using panels.

Panels Proposal:
The panels approach is very similar to the User Control approach. The
difference being that the panels are on one page rather than being broken out
to separate files. Of course now you have to maintain panel visibility and
such for the panel that allows input below the grid.

Which is faster? And why? And is there any documentation to back up your
answer?
 
K

Kevin Spencer

Hi Demitri,
Which is faster? And why? And is there any documentation to back up your
answer?

It's not a matter of which is faster. User Controls are compiled when used,
just like Pages. You're not going to see much difference, if any, in
performance.

What you really need to ask yourself is, which methodology is going to work
better for you? The nice thing about Controls, including User Controls, is
that, when designed correctly, they contain all of their own UI logic, and
encapsulate not only their child Controls but functionality as well. In
addition, if you ever need to re-use them, they are already pre-packaged for
reusability.

On the other hand, if there are not many Controls in these User Controls,
you may just elect to use Panels with Controls on them. It's really a matter
of good design.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
 

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,763
Messages
2,569,562
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top