User Controls Passing Variables from one control to another

Discussion in 'ASP .Net' started by Philip Poole, Sep 23, 2004.

  1. Philip Poole

    Philip Poole Guest

    Hello everyone,

    Please help with this as it is driving me up the wall and it is urgent i
    finish this page, this is the first time I have used User Controls and I
    think I must have completly misunderstood a basic point.

    I have a number of user controls which are used to make up my page. One
    control is a series of tabs which are created dynamically from a database.
    When someone clicks on a tab, the page reloads and the tabs that was clciked
    changes colour to signify it has been selected.

    The tabs to be displayed are decided by integer I set by a property.

    After the tabs has been created i then want to generate the rest of my page
    which wil be dependent on the id of the selected tab.

    At the moment I have in my template file (which contains all of the user
    controls) a page load method, in the page load method i call the functions
    to generate my page. However, this functions are dependent on the selected
    tab in the user control and the user control fuctions are not generated
    until after the page load of my template page. i.e

    Template.Page_Load() {

    generatePage(id) //but no id!!!!



    Whereas what I would like is

    Template.PageLoad() {
    //some function calls


    int id = SideTabs.SelectedTabId


    Is this possible? Or how can I get this type of functionaility.

    Please help

    Philip Poole, Sep 23, 2004
    1. Advertisements

  2. Josh

    Josh Guest

    Make your tab properties store thier data in the viewstate and have the
    other controls access that.
    Josh, Sep 23, 2004
    1. Advertisements

  3. Philip Poole

    Philip Poole Guest

    Hello Josh,

    Thankyou kindly for the advice

    do you have any idea on how I do that?


    "Josh" <> wrote in message
    > Make your tab properties store thier data in the viewstate and have the
    > other controls access that.
    Philip Poole, Sep 23, 2004
  4. Jim Corey

    Jim Corey Guest

    This scenario looks very similar to the Time Tracker starter kit at

    If SideTabs is a user control, then I don't think you want to explictly
    call its page_load event. You just want to load the control, probably
    by calling LoadControl.

    The specific control has to be loaded with each postback.
    Something that had me stumped for a long time is that you must also load
    a value to the id property of the control each time (I typically use the
    name of the control) and this helps the program keep everything in sync.

    A different approach would be to have one base control class for all the
    user controls, and put the functions there, but I don't know if that
    will help anything in your situation.


    *** Sent via Developersdex ***
    Don't just participate in USENET...get rewarded for it!
    Jim Corey, Sep 23, 2004
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe
    Jim Gibson
    Oct 1, 2003
  2. qwerty
    Scott Allen
    Sep 30, 2004
  3. =?Utf-8?B?REo=?=
    Dec 1, 2005
  4. hmikki
    Nathan Sokalski
    Oct 19, 2007
  5. Robert Cohen
    Andrew Durstewitz
    Jul 15, 2003

Share This Page