passing values between controls

Discussion in 'ASP .Net' started by evandela@bigpond.net.au, Mar 20, 2006.

  1. Guest

    Hi all, learning the asp.net is a slow process... but I am plodderign
    along. I have hit a bit of a snag - I have 4 pages of code here...
    control1.ascx
    control2.ascx
    default.asx... default.asx.vb

    relevant details (i think) on default.asx:
    <uc1:productList ID="ProductList1" runat="server"
    OnPreRender="getSelectedProduct" />
    <uc2:productDetails ID="ProductDetails1" runat="server" />

    on default.asx.vb:
    Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
    System.EventArgs)
    Response.Write("TEST: " & ProductList1.selectedProduct())
    End Sub

    To this point the system actually works. When i select a product in the
    1st User Control, it is displayed on the main page, however, I need to
    take this one step further... base what happens in UC2 on what has
    happened in UC1.

    what would I type in UC2, to reference to get the value of the
    selection in UC1 ?
     
    , Mar 20, 2006
    #1
    1. Advertising

  2. sloan Guest

    You need to think of your user controls as objects....

    and as an object, it can expose properties, read and/or write properties.

    public string PropertyOfUserControl1
    {
    get {return "this could be a member variable";}
    }


    Then you can read the property from uc1, and set a property of uc2.


    uc2.PropertyOfUserControl2 = uc1.PropertyOfUserControl1;


    If the code behind of uc2...you need to deal with the property you set.



    <> wrote in message
    news:...
    > Hi all, learning the asp.net is a slow process... but I am plodderign
    > along. I have hit a bit of a snag - I have 4 pages of code here...
    > control1.ascx
    > control2.ascx
    > default.asx... default.asx.vb
    >
    > relevant details (i think) on default.asx:
    > <uc1:productList ID="ProductList1" runat="server"
    > OnPreRender="getSelectedProduct" />
    > <uc2:productDetails ID="ProductDetails1" runat="server" />
    >
    > on default.asx.vb:
    > Protected Sub getSelectedProduct(ByVal sender As Object, ByVal e As
    > System.EventArgs)
    > Response.Write("TEST: " & ProductList1.selectedProduct())
    > End Sub
    >
    > To this point the system actually works. When i select a product in the
    > 1st User Control, it is displayed on the main page, however, I need to
    > take this one step further... base what happens in UC2 on what has
    > happened in UC1.
    >
    > what would I type in UC2, to reference to get the value of the
    > selection in UC1 ?
    >
     
    sloan, Mar 20, 2006
    #2
    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. cgia
    Replies:
    5
    Views:
    786
    Steve C. Orr, MCSD
    Jul 26, 2003
  2. Matt M
    Replies:
    1
    Views:
    1,129
    Matt M
    Aug 28, 2003
  3. Replies:
    0
    Views:
    409
  4. Arulraja

    Passing values between Custom controls?

    Arulraja, Oct 21, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    160
    Victor Garcia Aprea [MVP]
    Oct 23, 2003
  5. Peter K

    Passing values between user controls

    Peter K, Jan 13, 2010, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    1,162
    Nathan Sokalski
    Feb 18, 2010
Loading...

Share This Page