passing values between controls

E

evandela

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 ?
 
S

sloan

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,690
Latest member
MacGyver

Latest Threads

Top