Click here to Skip to main content
15,867,488 members
Articles / Web Development / ASP.NET
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
2.50/5 (2 votes)
30 Sep 2010CPOL 23.5K   3   3
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)


Written By
Chief Technology Officer Compuacademy.net
United States United States
More than 15 years of experience in design, architecture and development of various commercial objects oriented application.Other Specialties

Data Migration:
• MS Access database to SQL 2005/2008
• MS Access database to Oracle
• MS Access database to My SQL
• FoxPro to SQL

Application Migration:
• Converted MS Access application to .net web application (Asp.net)
• Excel Application to .net 3.5 web application
• FoxPro application to .net 3.5
Reporting development and support
• MS access reports
• Crystal reports
• SQL Reports(SSRS)
• DevExpress reports
• Cognos reports
Application development and support
• .net Application web /Win forms
• SharePoint
• MS Access
• Website
• Ecommerce
• WCF
• Web Services
3rd Party Control Support
• DevExpress
• .netForum
• Telerik
Version controls Support
• Team Foundation Server
• Source Safe
• CVS
• SVN

Comments and Discussions

 
GeneralMy vote of 3 Pin
Dev Sils10-Mar-14 2:48
Dev Sils10-Mar-14 2:48 
GeneralThis is not applicable when you are using Master pages. The ... Pin
Sharique Shueb5-Oct-10 1:32
Sharique Shueb5-Oct-10 1:32 
GeneralReason for my vote of 2 it can be easily find out on google Pin
Sandesh M Patil3-Oct-10 1:19
Sandesh M Patil3-Oct-10 1:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.