Referencing variables on user control pages

  • Thread starter Thread starter James Glover
  • Start date Start date
J

James Glover

I need to be able to reference a variable that is set in the code behind of
an aspx page in a user control embedded on the page.



An example:

The code behind sets a position number; say ,1 to 5. The included user
control is expecting that variable to know which element to highlight. (The
first through tenth LI tag in this example.)



The variable is declared globally prior to the page load on the aspx page
(i.e. int curNum = 0;) and is updated in subsequent functions depending on
the user's action. Any idea of how to pass this ID to an acsx page? Thanks
to all replies given.
 
James,

Why not just create a property on the page that exposes this id. Then,
from inside the user control, you can cast the return value of the Parent
property to the page type (or an interface that indicates it is a host for
that control), and then get the property value.

Hope this helps.
 
Back
Top