Sunday, 11 September 2016

Set UserControl Value On click of Button Present in another UserControl

Inline image 1Inline image 2


Write Below Code in UserControl1 

<%@ Reference VirtualPath="~/Control2.ascx" %>


On Button Click

 Control2 ctrlA = (Control2)Page.FindControl("Control_2");//Control_2 is the tagName that is used for Control2 in the aspx Page
 TextBox ddl = (TextBox)ctrlA.FindControl("txtResult");
//txtResult is the Textbox id Present in Control2
 ddl.Text = txtusername.Text;