Can you stop ASP.NET from changing IDs so that it can be used in jQuery

I have this label control in my web page using asp.net

< asp:Label ID="Label1" runat="server" Text="test">< /asp:Label >
And when the page rendered the id of the control changes to something like this

< span id="ctl00_ContentPlaceHolder1_Label1">test< /span >
How can I stop asp.net from changing IDs in order to perform a jQuery operation like this

$('#label1').html(xml);

Greg from Gemantown

One thought on “Can you stop ASP.NET from changing IDs so that it can be used in jQuery

  1. Hello Greg

    I do not believe that there is a way to stop the ids from changing but you can use this one, which is basically using the classic asp inline server side code.

    $('#< %= Label1.ClientID %>')

    this will insert whatever ID that is generated to be placed as a literal in asp.net.
    Will

Comments are closed.