You can use either text()
or html()
.
<asp:Label runat="server" ID="LastNameLabel" Text="This is a text"
ClientIDMode="Static"></asp:Label>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var text = $("#LastNameLabel").text();
alert(text);
});
</script>
Update:
Make sure to use ClientIDMode="Static"
since LastNameLabel
's Id is not available outside of FormView
.
Then you can just use #LastNameLabel
in jQuery selector.