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?
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.
Here is an example:
Declare On User Control (PrevTransList2.ascx.cs)
public string TransHxPage
{
get
{
return name;
}
set
{
name = value;
}
}
On Class file
public interface IUserControlTransHx
{
string TransHxPage { get; set; }
}
txtSomthing.Text = TransHxPage;
Now On Web page SET its values
PrevTransList2.TransHxPage = "POSP";