Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

How to get Value from from usercontrol to aspx page using Javascript

2.50/5 (2 votes)
30 Sep 2010CPOL 24.2K  
Pass value between user control and aspx page
XML
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>TanvTech Code</title>
     <script type="text/javascript">
 function GetDatafromControl()
 {
    var val=document.forms[0]['MyAccessValueFromUserControl_AccessNameTextBox'];
        document.forms[0].NameTextBox.value=val.value
 }
 </script>
</head>

<body>
    <form id="form1" runat="server">
    <div>
    <table>
    <tr>
    <td style="width: 210px">
        <uc1:AccessValueFromUserControl id="MyAccessValueFromUserControl" runat="server">
        </uc1:AccessValueFromUserControl></td>
    <td style="width: 359px">
        <asp:TextBox ID="NameTextBox" runat="server" ></asp:TextBox>
        <asp:Button ID="GetButton" runat="server"  OnClientClick="GetDatafromControl();" Text="Get"  OnClick="GetButton_Click"/></td>
    </tr>
    </table>
    </div>
    </form>
</body>
</html>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)