How to access one usercontrol to another control using c#? -


i have 2 user controller test1.ascx & test2.ascx. how access test1.ascx within test2.ascx.

example: test1.ascx.cs have follwing method:

public string test() {    return "welcome user control 1"; } 

in test2.axcs.cs

public void page_load(object obj, sender e)     {        test1();     }  public string test1()    {         return "welcome user control 2";    } 

i access second user control(test2.ascx.cs) within test1.ascx.cs.

please me solve.

you can register test2.ascx in test1.ascx test1.ascx

<%@ register src="test2.ascx" tagname="temp2" tagprefix="uc2" %> <uc2:temp2 id="temp21" runat="server" /> 

test1.ascx.cs

public string test() {    return temp21.test1; // output "welcome user control 2" } 

Comments