ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Pass (Send) data from aspx page to UserControl using C# and VB.Net<p>Hi <a class="username" rel="rajus"> rajus</a>,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <p><strong>WebUserControl.ascx</strong></p> <pre class="brush: csharp">Name: &lt;asp:Label ID=&#34;lblName&#34; runat=&#34;server&#34; /&gt;</pre> <p><strong>Default.aspx</strong></p> <pre class="brush: html">&lt;%@ Register Src=&#34;~/WebUserControl.ascx&#34; TagName=&#34;ucName&#34; TagPrefix=&#34;uc&#34; %&gt; &lt;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&gt; &lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &nbsp;&nbsp;&nbsp; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &nbsp;&nbsp;&nbsp; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &nbsp;&nbsp;&nbsp; &lt;div&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:TextBox ID=&#34;txtName&#34; runat=&#34;server&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;asp:Button Text=&#34;Submit&#34; runat=&#34;server&#34; OnClick=&#34;Submit&#34; /&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;uc:ucName ID=&#34;ucName&#34; runat=&#34;server&#34;&gt;&lt;/uc:ucName&gt; &nbsp;&nbsp;&nbsp; &lt;/div&gt; &nbsp;&nbsp;&nbsp; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>WebUserControl.ascx</strong>.<strong>cs</strong></p> <pre class="brush: csharp">public string Name { get { return lblName.Text; } set { lblName.Text = value; } }</pre> <p><strong>WebUserControl.ascx</strong>.<strong>vb</strong></p> <pre class="brush: vb">Public Property Name As String Get Return lblName.Text End Get Set(ByVal value As String) lblName.Text = value End Set End Property</pre> <p><strong>Default.aspx</strong>.<strong>cs</strong></p> <pre class="brush: csharp">protected void Submit(object sender, EventArgs e) { ucName.Name = txtName.Text; }</pre> <p><strong>Default.aspx.vb</strong></p> <pre class="brush: vb">Protected Sub Submit(ByVal sender As Object, ByVal e As EventArgs) ucName.Name = txtName.Text End Sub</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><img src="https://i.imgur.com/ejRZFXl.jpg" alt="" width="312" height="60" /></p>https://www.aspforums.net:443/Threads/497721/Pass-Send-data-from-aspx-page-to-UserControl-using-C-and-VBNet/https://www.aspforums.net:443/Threads/497721/Pass-Send-data-from-aspx-page-to-UserControl-using-C-and-VBNet/Mon, 28 May 2018 08:14:33 GMT