Passing values between two ascx's

I have an ascx containing another ascx and I’d like to have it pass on the value/text of its label control (or imageurl) to another ascx. How would I do that? Please mention the code on both ascx’s.

i think you have to you profiles or session variables. in my openion there is no other way.

Nope, there are lots of other ways. Is this a value you’d know at runtime or a value you’d only know at design time?

create a public method on the second control.

public void SetStuffs(string text,string val)
{
mylabel.text=text;
//-----------whatever you wanna do
}

now on the first control
<%@ Register Src=“~/A.ascx” TagName=“control” TagPrefix=“MC” %>

<MC:control ID=“mycontrol” runat=“server” />

call the method on code behind
mycontrol.SetStuffs(“text”,“val”);

It’s odd in that in the control I like to set the boolean value, I can’t pass it where I get the conditional result on which the value is based.

In the receiving control (control1):
(if control2.IsThisTrue) then {do something…}

In the passing control (control2):
private bool _blnIsThisTrue = true; //this is one place the value can be passed to control1

public bool IsThisTrue { set { _blnIsThisTrue = value; } get { return _blnIsThisTrue; } }

But in the method deciding the boolean value, control1 doesn’t seem to get it, even though I tried to simply set _blnIsThisTrue unconditionally to be true.

private void DisplayFilter(Filter filter, DataListItemEventArgs e) {
	Label lblFilter = (Label) e.Item.FindControl("lblFilter");
	if (lblFilter == null) throw new NullReferenceException("Your filter label does not exist.");
			
        string strFilter = string.Empty;
			
        switch (filter.FilterType) {
               case.....
               strFilter = something;
               break;
               case..... //set in this case
               strFilter = something;
               _blnIsThisTrue = true
	       break;
        }
}

So where I can set it? I can’t translate the condition into a public method where I know I can set it.

The problem is that the condition can only be checked in that datalist control due to the legacy code design. My question is why I can’t set the boolean value of a private variable (or any variables for that matter) within the same ascx based on the condition I checked in one iteration of that filtering loop? As long as I can somehow set it and pass it to my public method the other controls can read it off there fine.

I can pass variables around ascx controls fine. I just can’t set the value of a member variable within a datalist as:
dlstFilters_onItemDataBound(object sender, DataListItemEventArgs e) {…}
And it doesn’t make sense why I can’t do that. Can anyone out there help me figure it out?

I found the solution that circumvents the problem.