Question

I have a website that regularly has 500 simultaneous viewers. I am looking for some guidelines for using ASCX controls.

I want to make sure that the website has a fast response time, but I also want to re-use my code.

I am creating a custom control that displays a table full of information. The table is paginated (containing page numbers and prev/next buttons above the table). I want this control to be reusable and in some cases the page numbers may be displayed below the table as well or instead of above it.
I am aware of the GridView Control, but I want a custom control in this case.

Should I create a separate control for the page numbers? Or should I have one large control with top buttons, middle content, and bottom buttons all in it? The page numbers are derived from the same data that the data table is derived from. If I create separate controls I will need to pull this data each time the control is called from the page correct?

How would you do this?

Was it helpful?

Solution

In that case you probably want a single control.

You might make multiple custom controls (one for the page numbers, one for the table, etc.) and then another one that aggregates the simpler ones into your master view of the data.

One thing thouh, I would definitely make sure to decouple the data from the presentation. Don't tie your control to the data!

The rule above implies for instance that when making your control to represent the page numbers, or the buttons, those should be abstract enough to be controlled by your master control, or to represent actions on the _master_control not necessarily interact with the data of the master control directly.

OTHER TIPS

Do you anticipate creating grids without pagination? If you do, it might be good to make them separate controls. However, if you decide to make it one big control, code it in a way that makes separating them easy.

If performance is an issue, make sure that your controls output the least amount of HTML possible, and cache your outputs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top