What Component model to use??

G

GaryB

I have an ASPX page and a vb codebehind file that takes as input a passed
web datagrid as input. My page has a CrystalReportsViewer on it. My page
produces a PDF report of the DataGrid that was passed.

I want to package this functionality into a component so that a programmer
can simply drop my control onto an aspx page, enter the name of a datagrid
on that page to enable print functionality for that grid.

Going through some books on creating components and controls I haven't seen
an example of components that produce web pages as does my program.

What is the best component template to use for this kind of thing?
Thanks,
Gary
 
J

John Saunders

GaryB said:
I have an ASPX page and a vb codebehind file that takes as input a passed
web datagrid as input. My page has a CrystalReportsViewer on it. My page
produces a PDF report of the DataGrid that was passed.

I want to package this functionality into a component so that a programmer
can simply drop my control onto an aspx page, enter the name of a datagrid
on that page to enable print functionality for that grid.

Going through some books on creating components and controls I haven't
seen an example of components that produce web pages as does my program.

What is the best component template to use for this kind of thing?

Get and read "Developing Microsoft® ASP.NET Server Controls and Components"
from Microsoft Press, by Nikhil Kothari and Vandana Datye
(http://www.microsoft.com/mspress/books/5728.asp)



Also, the DataGrid is a presentation component, not a data component. Don't
pass that around unless your goal is to create a PDF version of the HTML
produced by the DataGrid. Otherwise, pass the data, not the grid.



If you are trying to produce PDF from the HTML, then make the parameter
containing the DataGrid of type System.Web.UI.Control, which will give your
callers the flexibility of changing to a different display control.



John Saunders
 
S

Steven Cheng[MSFT]

Thanks for John's suggestions.

Hi Gary,

AS for the problem you mentioned, I think a Custom Server Control is more
suitable than a Component since
web server control can be put in the aspx page's page template and be
parsed by page at runtime while the component is only a page member
instance which can't be persistence in the page's template and can't easily
make use of the page's control tree.
You can define such a custom web server control which has a custom propety
which is the DataGrid ( it want to use) 's ID so that at runtime the
Control can use this property to find the DataGrid control instance in the
Control tree. Also, it is recommend that you alwasy put this custom control
and the datagrid it want to use in the same NamingContainer parent control
so that you can directly use the Control.NamingContainer.FindControl(
control id) to get the control in the same parent NamingContainer. This is
just something like how the
RequiredFieldValidator control work with a TextBox (it will validate).

Just some of my opinions. Hope helps.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top