Basic of JQuery Get or Set Controls Values in Asp.Net

Basic of JQuery Get or Set Controls Values in Asp.Net 

How to Access Basic Asp.Net Controls Using in JQuery.
  Basic JQuery Use To Get Or Set Values Using Asp.NET Controls.

Download Coding

HTML CODING

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
   <script type="text/javascript">
      
       // Button Click or Not

       $(document).ready(function(){
           $("#Button1").click(function(){          
               alert("Button Clicked");
           });
       });

       // Label Value Get Button Click

       $(document).ready(function () {
           $("#Button1").click(function () {            
               var lbl = $("#Label1").html();
               alert(lbl);
           });
       });

       // Textbox Values Get Button Click

       $(document).ready(function () {
           $("#Button1").click(function () {            
               alert($("#TextBox1").val());
           });
       });

       // DropDownlist Selected Values Get After Button Click

       $(document).ready(function ()
       {
           $("#Button1").click(function ()
           {
              alert($('#<%=DropDownList1.ClientID%>').text());
              alert($('#<%=DropDownList1.ClientID%>').val());
           });
       });

       // CheckBox Check Checked or Unchecked

       $(document).ready(function () {
           $("#Button1").click(function () {
               if ($("#CheckBox1").is(':checked')) {
                   alert('CheckBox Checked')
               }
               else {
                   alert('CheckBox Unchecked')
               }
           })

       })
     

       // Radiobutton Ckeck Checked or Unchecked

       $(document).ready(function () {
           $("#RadioButton1").click(function ()
           {
               ($("#<%=RadioButton1.ClientID%>").attr('checked',true))
               {
                   alert($("#RadioButton1").val());
               }             

           });
       });

   </script>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
        <asp:Button ID="Button1" runat="server" Text="Button"  />
        <asp:CheckBox ID="CheckBox1" Text="Checkbox" runat="server"  />
        <asp:Label ID="Label1" runat="server"  Text="Dotnet"></asp:Label>
        <asp:TextBox ID="TextBox1" Text="Dotnet" runat="server"></asp:TextBox>
        <asp:DropDownList ID="DropDownList1"  runat="server">
            <asp:ListItem>A</asp:ListItem>
            <asp:ListItem>B</asp:ListItem>
            <asp:ListItem>C</asp:ListItem>
        </asp:DropDownList>
        <asp:RadioButton ID="RadioButton1" Text="RadioButton"  runat="server" GroupName=""/>

    </div>
    </form>
</body>
</html>

DEMO

 // Button Click or Not

 $(document).ready(function(){
           $("#Button1").click(function(){          
               alert("Button Clicked");
           });
       });



// CheckBox Check Checked or Unchecked

       $(document).ready(function () {
           $("#Button1").click(function () {
               if ($("#CheckBox1").is(':checked')) {
                   alert('CheckBox Checked')
               }
               else {
                   alert('CheckBox Unchecked')
               }
           })

       })


 // Label Value Get Button Click

       $(document).ready(function () {
           $("#Button1").click(function () {            
               var lbl = $("#Label1").html();
               alert(lbl);
           });
       });





 // Textbox Values Get Button Click

       $(document).ready(function () {
           $("#Button1").click(function () {            
               alert($("#TextBox1").val());
           });
       });



 // DropDownlist Selected Values Get After Button Click

       $(document).ready(function ()
       {
           $("#Button1").click(function ()
           {
             alert($('#<%=DropDownList1.ClientID%>').val());
           });
       });








 // DropDownlist Selected Values Get After Button Click

       $(document).ready(function ()
       {
           $("#Button1").click(function ()
           {
              alert($('#<%=DropDownList1.ClientID%>').text());
             
           });
       });





       // Radiobutton Ckeck Checked or Unchecked

       $(document).ready(function () {
           $("#RadioButton1").click(function ()
           {
               ($("#<%=RadioButton1.ClientID%>").attr('checked',true))
               {
                   alert($("#RadioButton1").val());
               }             

           });
       });









0 comments:

Post a Comment