Return to Snippet

Revision: 59508
at September 13, 2012 04:37 by rumremix


Initial Code
<%--jQuery example -->

<script>
$('#<%=Step1.ClientID %>').someFunction();
</script>

<%--CSS example -->
<style>
#<%=Step1.ClientID %> {some style...}
</style>

Initial URL


Initial Description
In the examples, below, Step1 is the id  given to the element. If the element is set to runat="server", when it is rendered on the page, the id will change dynamically to something like ctl00$PlaceHolderMain$Step1. But the actual value may change. To make sure we capture the correct value to manipulate the element in javascript or CSS, use the technique below. Note that this code will need to live on the same page as the element, not in an external js or css file.

Initial Title
how to use dynamically generated .Net element IDs on page in jquery or css

Initial Tags
Net

Initial Language
ASP