Search code examples
asp.netvb.netuser-controlsweb-controls

Get value from text box in User Control from Web Page


I have this Web Control call uc_Register.asxc Inside this web control got a Text Box i.e txtName

I add this Web Control into my web page call register.aspx

<%@ Register Src="~/controls/uc_Register.ascx" TagPrefix="ecommmbs" TagName="uc_Register" %>
<hr />
<ecommmbs:uc_SummaryCart runat="server" ID="uc_SummaryCart" />
<hr />

i want to get the value from txtName.txt from uc_Register.asxc at register.aspx. how to make this happen?


Solution

  • Try this in Register.aspx

    TextBox txtbox = (TextBox)uc_Register.FindControl("txtName");
    

    but keep in mind Page_Load() of aspx page is called first than Page_Load()of .ascx is called.