asp.net - Find property of sub child usercontrol in aspx page -


there user control - childuc.ascx property "firstname"

childuc.ascx

<%@ control language="c#" autoeventwireup="true" codebehind="childuc.ascx.cs" inherits="sampledevexpress14._2.usercontrols.childuc" %> <asp:textbox runat="server" id="txtname"></asp:textbox> <asp:button runat="server" id="btnclick" text="click" onclick="btnclick_click"/> 

childuc.ascx.cs - got property firstname

public partial class childuc : system.web.ui.usercontrol     {         public string firstname { get; set; }     } 

this childuc.ascx user control used in user control parentuc.ascx-

parentuc.ascx

<%@ control language="c#" autoeventwireup="true" codebehind="parentuc.ascx.cs" inherits="sampledevexpress14._2.usercontrols.parentuc" %> <%@ register src="childuc.ascx" tagprefix="uc1" tagname="childuc" %>  <uc1:childuc runat="server" id="ucchilduc"/> 

the parentuc.ascx used in parentpage.aspx

parentpage.aspx

<%@ page language="c#" autoeventwireup="true" codebehind="parentpage.aspx.cs" inherits="sampledevexpress14._2.usercontrols.parentpage" %> <%@register src="parentuc.ascx" tagprefix="uc1" tagname="parentuc" %> <html xmlns="http://www.w3.org/1999/xhtml"> <body>     <form id="form1" runat="server">     <div>         <uc1:parentuc runat="server" id="ucparentuc"/>         </div>     </form> </body> </html> 

parentpage.aspx.cs

protected void page_load(object sender, eventargs e)         {             usercontrol ucchild = (usercontrol)ucparentuc.findcontrol("ucchilduc");             textbox txtnameofchilduc = (textbox)ucchild.findcontrol("txtname");             txtnameofchilduc.text = "from parent page";         } 

i able find textbox control of childuc.ascx in parentpage.aspx showed above in page_load event

but how can find firstname property of childuc.ascx in parentpage.aspx , set value it.

thank you.

trying using dynamic,

    dynamic u = (usercontrol)parentcontrol.findcontrol("childcontrol");     u.firstname = "fawad";     response.write(u.firstname); 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -