How to get label text using jquery in all browser.

Posted by Sahoo under ASP.NET on 10/12/2012 | Points: 10 | Views : 9342 | Status : [Member] | Replies : 1
Hi I have a label control let say

<asp:Label ID="lblMessage" runat="server" text="Please use less than 1000 characters"/>.

I want to access the label text "Please use less than 1000 characters" using JQYERY/Javascript .Please suggest.



Posted by: Dharanidhar on: 10/12/2012 [Member] Starter | Points: 25

Hi Sahoo,
You can get the asp:label Text using Jquery as below:

$('#<%=lblMessage.ClientID %>').html()

$('#<%=lblMessage.ClientID %>').text()



You can use any one of the above.It gets the label text..
For easy Understanding,I am Getting the text of asp:label control and putting in the alert so that the label text is displayed as alert as below:

 <script type="text/javascript">

$(document).ready(function () {
alert($('#<%=lblMessage.ClientID %>').html());


The above code displays the label text as alert boxes..U can also use text() instead of html() in the above code.

Thank You,

Sahoo, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response