Newbee: Passing Integer to User Control

D

DotNet

I'm trying to construct a header user control and would like to pass an
integer to the control in order to display the correct on state for a menu.
How does one pass an integer from an .aspx page to an .ascx page when the
page loads?

Thanks.
 
K

Kevin Spencer

It sounds like you're migrating from ASP to ASP.Net, in that your thinking
procedurally rather than object-orieted. In ASP.Net it is more useful to
think about objects and classes than files. A Page is a class. A User
Control is a class. Therefore, you would not "pass" data from one class to
the other. You set properties. Now, you can also call Methods in a class,
and pass them data. So, you have 2 choices: (1) Set a property, and (2) Call
a method.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
C

Curt_C [MVP]

in the ASCX you can use the Request.Querystring if it's there,
otherwise you may need to create a public property in the control to pass it
to
 
D

DotNet

I'm really having trouble getting the public property in the control to
work. Can you supply a simple example of the aspx and ascx pages? Nothing
elaborate just a really basic code sample.

Thanks.
 
D

DotNet

Exactly right you are. I realize this is a simple concept, but migrating the
architecture is a challenge. We'd like to keep the project template driven -
our headers dynamically generate menu HTML code. I "think" that a user
control method is best for that - but if I'm wrong, please let me know. We
are trying to seperate HTML from logic, so if there is a better or more
sensible way of going about this can you let me know?

-w
 
K

Kevin Spencer

Sounds like you're on the right track. We've been looking at CSS for better
separation of UI logic and presentation. But your method for generating a
common menu system seems sound.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top