65.9K
CodeProject is changing. Read more.
Home

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

starIconstarIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIcon

2.50/5 (2 votes)

Sep 20, 2010

CPOL
viewsIcon

24258

Pass value between user control and aspx page

<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>