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!!!!

    }

    SideTabs.Page_Load()

    Whereas what I would like is

    Template.PageLoad() {
    //some function calls

    SideTabs.PageLoad()

    int id = SideTabs.SelectedTabId

    GenerateContent(id)
    }

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

    Please help

    Philip
    Philip Poole, Sep 23, 2004
    #1
    1. Advertising

  2. Philip Poole

    Josh Guest

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

  3. Philip Poole

    Philip Poole Guest

    Hello Josh,

    Thankyou kindly for the advice

    do you have any idea on how I do that?

    Phil


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

    Jim Corey Guest

    This scenario looks very similar to the Time Tracker starter kit at
    www.asp.net.

    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.

    Jim


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Jim Corey, Sep 23, 2004
    #4
    1. Advertising

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
    Replies:
    1
    Views:
    1,154
    Jim Gibson
    Oct 1, 2003
  2. qwerty
    Replies:
    3
    Views:
    9,281
    Scott Allen
    Sep 30, 2004
  3. =?Utf-8?B?REo=?=
    Replies:
    2
    Views:
    469
    =?Utf-8?B?REo=?=
    Dec 1, 2005
  4. hmikki
    Replies:
    1
    Views:
    141
    Nathan Sokalski
    Oct 19, 2007
  5. Robert Cohen
    Replies:
    3
    Views:
    270
    Andrew Durstewitz
    Jul 15, 2003
Loading...

Share This Page