Get (Retrieve) TextBox value inside UserControl using jQuery in ASP.Net

SajidHussa
 
on Mar 12, 2020 02:21 AM
Sample_952359.zip
1847 Views

How to get the value of textbox and any other control which is define inside user contral by using jquery

Download FREE API for Word, Excel and PDF in ASP.Net: Download
arunkurmi
 
on Mar 13, 2020 07:20 AM
on Mar 13, 2020 07:22 AM

Hi SajidHussa,

Check this sample. now take its reference.

UserControl.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs"
    Inherits="WebUserControl" %>
Enter Mobile No :
<input id="txtMobileNo" type="text" placeholder="Enter Your Registered Mobile Number" />

HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $("[id*=btnSubmit]").on("click", function () {
                var number = $('[id*=txtMobileNo]').val();
                alert(number);
            });
        });
    </script>
    <form id="form1" runat="server">
    <div>
        <uc1:UserControl ID="UserControl1" runat="server" />
        <br />
        <asp:Button ID="btnSubmit" Text="Submit" runat="server" />
    </div>
    </form>
</body>
</html>

Screenshot