Accessing value from the controls within a dynamically loaded web user control (asp.net c#)
<p>I have created a web user control (MemberDetails.ascx) which is loaded dynamically on a page (Member.aspx) for my website. The control has some TextBoxes. I want to store the values inputted by a user in these TextBoxes to a database on the click event of a button that is on the Member.aspx page (i.e. not a part of user control).</p>

<p>I'll use a small code for example.</p>

<p>Member.ascx page:</p>

<pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="MemberDetails.ascx.cs" Inherits="Users_MemberDetails" %&gt;
&lt;div align="center"&gt;
&lt;table runat="server" align="center" bordercolor="Black" id="tbl1"&gt;
&lt;tr&gt;
&lt;td&gt;First Name:&lt;/td&gt;&lt;td&gt;&lt;asp:TextBox ID="txtFname" runat="server" /&gt;&lt;/td&gt;
&lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;Last Name:&lt;/td&gt;&lt;td&gt;&lt;asp:TextBox ID="txtLname" runat="server" /&gt;&lt;/td&gt;
   &lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
</code></pre>

<p>Member.aspx.cs :</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Users_Booking : System.Web.UI.Page
{

 protected void Page_Load(object sender, EventArgs e)
 {
    UserControl Memberuc;
    Memberuc = (UserControl)LoadControl("MemberDetails.ascx");
    Memberuc.ID = "Memberuc1";
    PlaceHolder1.Controls.Add(Memberuc);
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
   /*Code for saving the input to a database*/
 }
}
</code></pre>

<p>I have tried several methods (using properties and FindControl etc.) to do it using suggestions on various forums, but nothing worked for me. Please post the required code.
Thanks.</p>
