jQuery and ASP.NET

April 23, 2009

Get the Client ID of an ASP.NET Control in jQuery




While navigating the DOM using jQuery, it is often necessary to get the id of the control and perform operations on it, like hiding the control.

However, if you are using an ASP.NET Master Page and would like to retrieve the ClientId of a control using jQuery, then here's how to do so:


<html xmlns="http://www.w3.org/1999/xhtml">


<head runat="server">


<title></title>


<script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>


<script type="text/javascript">


    $(document).ready(function() {


        $("#<%=RadioButtonList1.ClientID %>").hide('slow');


    });    


</script>


</head>


<body>


<form id="form1" runat="server">


<div>   


<asp:RadioButtonList ID="RadioButtonList1"  runat="server">


<asp:ListItem Value="Ten"></asp:ListItem>


<asp:ListItem Value="Twenty"></asp:ListItem>


<asp:ListItem Value="Thirty"></asp:ListItem>


<asp:ListItem Value="Forty"></asp:ListItem>


</asp:RadioButtonList>




The example shown above fetches the ClientId of the RadioButtonList and hides it using jQuery


Bookmark this link on del.icio.us (saved by 0 users)

Did you like this post?
kick it on DotNetKicks.com
subscribe via rss subscribe via e-mail
print this post follow me on twitter
Others Also Read..

comments

0 Responses to "Get the Client ID of an ASP.NET Control in jQuery"
 

Copyright 2010 All Rights Reserved DevCurry.com by Suprotim Agarwal