Calling Property and method of a user control from another user control

Dec 20 2006 10:38 PM
I have Created a property "SetExContent" and a method populateScreen()
in UserControl2.ascx.cs

private string setExContent;

public string SetExContent
        {
            get
            {
                return setExContent;
            }
            set
            {
                setExContent = value;
            }
        }

public void populateScreen()
{

string totContent = SetExContent;

//Populate all the fields of Usercontrol2 from totContent.


}


In User Contol1 I have

<asp:HiddenField ID="testhid" EnableViewState="true" runat="server" />
<asp:Button ID="Button2" runat="server" OnClientClick="document.all('testhid').value = window.clipboardData.getData('Text')" OnClick="Button2_Click" Text="Paste & Populate UI" />

In userControl1.cs button click I want to set the property of SetExContent user control2 and call the metod populate screen.

void button2_click
{

usercontrol1.SetExContent = testhid.value; //Set user control2 property

populateScreen(); //Call user control2 method


}


How do I call user control2 property and method on user control1 button click.Pls provide the code.




------------------------------------------------------


For your Info--

The two user controls are getting loaded in a page pagemail.aspx which has a code like this
------------------------
private string userControl1Path = "UserControls/userControl1.ascx";
private string userControl2Path = "UserControls/usercontrol2.ascx";

UserControls.UserControl1 userControl1;            
UserControls.UserControl2 userControl1;

          

userControl1 = this.Page.LoadControl(this.userControl1Path) as UserControls.UserControl1;
 this.controlHolder.Controls.Add(UserControl1);


                   userControl2 = this.Page.LoadControl(this.userControl2Path) as UserControls.UserControl2;
 this.controlHolder.Controls.Add(UserControl2);                    


------------------------------