What you want to do seems fairly straightforward. You just need to create a
user control, which you can use the visual designer to do. Then, you need to
go in to the code behind and customize based on your needs. Let me see if I
can expand your scenario in a way that is meaningful. You want to get
information from SQL Server, and what you intend to display is dependent on
what page you are sitting on. Well, then your develop a user control that
displays a generic DataGrid that you can later databind to some (still to be
defined) data source. Then, you can access the hosting page using the Parent
property of that control, if the information is there. Or, you could store
that information in a session variable. There are countless ways to
develop - you have a completely object oriented environment in which to
play, and you just need to design your architecture so you can phrase your
"question" to this user control in a completely generic way. In fact, I have
several sites that contain only a single aspx control, and the entire
application logic determines what user controls should be loaded, and what
data they could contain. The framework is extremely powerful. If you can
phrase your question more specifically, then perhaps we can give you tips
and tricks to get you to the answer in the most efficient way - just wanting
to reuse code is a question that the UserControl class answers rather
succinctly.
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Lloyd Sheen" <sq*******************@tostopspamhotmail.com> wrote in message
news:Ib******************@news01.bloor.is.net.cabl e.rogers.com...
What I am trying to do is use code that works on one page in other pages.
It is a set of controls that access information from a SQL Server and
populate a list depending on certain criteria.
I need to have the same functionallity on several pages. This is what I
would think is the best cause for the use of user controls.
I am new to ASP.NET and have taken the idea of a user control from
previous VS types (VB6). I would think you could create a user control for ASP by
creating the child controls, add code to put functionallity to those
controls (server side) and then be able to add that control to ASP pages.
This does not seem to be a viable thing to do in VS 2003.