Newbee: Passing Integer to User Control

  • Thread starter Thread starter DotNet
  • Start date Start date
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.
 
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.
 
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
 
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.
 
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
 
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.
 
Back
Top