How to Get the ClientID in ASP
ASP.NET is a framework for web developers that allows you to create dynamic web pages and applications by utilizing code-based programming tools. Each page you create with the programming language will have dozens of elements that are tied into the page's ClientID. This attribute identifies the page, allowing any corresponding elements to then be loaded. If you are creating elements for the page, such as a CSS page, you can get the page's ClientID from ASP.NET.
Instructions
-
-
1
Open your ASP.NET Master Page, which is typically the home page, in the web-editing program of your choice. Anything from Notepad to Adobe Dreamweaver will be fine.
-
2
Create a copy of the file. This will allow you to make any changes to the file without ever making any changes to your actual site.
-
-
3
Erase any code on the page and type the command that creates a page that displays the ClientID:
<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>
</body>
</html>This will create a radio button that displays the ClientID, except the radio button will be hidden.
-
4
Save the file and open it in the web browser of your choice. Once opened, the only content displayed on the page will be the ClientID of your ASP.NET page. You may then use this in the actual file of your ASP.NET Master Page.
-
1