0

1. I have a blank test page. On the page load, it does this:

UserControl c1 = (UserControl)LoadControl("control1.ascx");

this.Controls.Add(c1);

2. I have control1.ascx.cs On the ascx side: i have this single literal:

<asp:Literal ID="litTest1" runat="server" Text="Hello World" />

On the page load, it does:

UserControl c2 = (UserControl)LoadControl("control2.ascx");

this.Controls.Add(c2);

3. i have control2.ascx.cs On the ascx side: I have the following literal:

<asp:Literal ID="litTest2" runat="server" Text="Hello Universe" />

on the ascx.cs side it has:

public string sTest2 = "Hello Existence";

The literals I added was to ensure that the page calls control1 and control1 is calling control2, which it does. On execution I get to see hello World & Hello universe messages, no problem, but NOW, I am trying to get the variable sTest on control2 inside the page load of control1. I want to be able to set that variable from control1.
is that possible? If so, how?

2
Contributors
1
Reply
4
Views
7 Years
Discussion Span
Last Post by reach_yousuf
0

1. I have a blank test page. On the page load, it does this:

UserControl c1 = (UserControl)LoadControl("control1.ascx");

this.Controls.Add(c1);

2. I have control1.ascx.cs On the ascx side: i have this single literal:

<asp:Literal ID="litTest1" runat="server" Text="Hello World" />

On the page load, it does:

UserControl c2 = (UserControl)LoadControl("control2.ascx");

this.Controls.Add(c2);

3. i have control2.ascx.cs On the ascx side: I have the following literal:

<asp:Literal ID="litTest2" runat="server" Text="Hello Universe" />

on the ascx.cs side it has:

public string sTest2 = "Hello Existence";

The literals I added was to ensure that the page calls control1 and control1 is calling control2, which it does. On execution I get to see hello World & Hello universe messages, no problem, but NOW, I am trying to get the variable sTest on control2 inside the page load of control1. I want to be able to set that variable from control1.
is that possible? If so, how?

Hi bigfan

Use session variable

'to assign value
Session("Control1value") = "yourvalue"

'to retrieve value from session
mytextbox.text = Session("Control1value")

If it helps you, mark as solved!!!

Edited by reach_yousuf: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.