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.Send DropDownList selected value inside UserControl to another UserControl Label using JavaScript in ASP.Net<p>Hi <a class="username" rel="rsmldmv"> rsmldmv</a>,</p> <p>Please refer below sample.</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <p><strong>WebUserControl.ascx</strong></p> <pre class="brush: html">&lt;%@ Control Language=&#34;C#&#34; AutoEventWireup=&#34;true&#34; CodeFile=&#34;WebUserControl.ascx.cs&#34; Inherits=&#34;WebUserControl&#34; %&gt; &lt;asp:DropDownList ID=&#34;ddlFruits&#34; runat=&#34;server&#34; onchange=&#34;GetSelectedTextValue(this)&#34;&gt; &lt;asp:ListItem Text=&#34;Mango&#34; Value=&#34;1&#34;&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text=&#34;Grapes&#34; Value=&#34;2&#34;&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text=&#34;Banana&#34; Value=&#34;3&#34;&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text=&#34;Apples&#34; Value=&#34;4&#34;&gt;&lt;/asp:ListItem&gt; &lt;/asp:DropDownList&gt; </pre> <p><strong>WebUserControl2.ascx</strong></p> <pre class="brush: html">&lt;%@ Control Language=&#34;C#&#34; AutoEventWireup=&#34;true&#34; CodeFile=&#34;WebUserControl2.ascx.cs&#34; Inherits=&#34;WebUserControl2&#34; %&gt; &lt;asp:Label ID=&#34;lblMessage&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt;</pre> <p><strong>Default.aspx</strong></p> <pre class="brush: html">&lt;%@ Page Language=&#34;C#&#34; AutoEventWireup=&#34;true&#34; CodeFile=&#34;Default.aspx.cs&#34; Inherits=&#34;_Default&#34; %&gt; &lt;%@ Register Src=&#34;~/WebUserControl.ascx&#34; TagPrefix=&#34;uc1&#34; TagName=&#34;WebUserControl&#34; %&gt; &lt;%@ Register Src=&#34;~/WebUserControl2.ascx&#34; TagPrefix=&#34;uc2&#34; TagName=&#34;WebUserControl&#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; &lt;title&gt;&lt;/title&gt; &lt;script type=&#34;text/javascript&#34;&gt; function GetSelectedTextValue(ddlFruits) { var selectedText = ddlFruits.options[ddlFruits.selectedIndex].value; document.getElementById(&#39;WebUserControl2_lblMessage&#39;).innerHTML = selectedText; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;div&gt; &lt;uc1:WebUserControl runat=&#34;server&#34; ID=&#34;WebUserControl1&#34; /&gt; &lt;uc2:WebUserControl runat=&#34;server&#34; ID=&#34;WebUserControl2&#34; /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://i.imgur.com/zy848m0.gif" alt="" width="273" height="157" /></p>https://www.aspforums.net:443/Threads/107928/Send-DropDownList-selected-value-inside-UserControl-to-another-UserControl-Label-using-JavaScript-in-ASPNet/https://www.aspforums.net:443/Threads/107928/Send-DropDownList-selected-value-inside-UserControl-to-another-UserControl-Label-using-JavaScript-in-ASPNet/Mon, 20 Aug 2018 01:13:25 GMT