Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 384 Vote(s) - 3.48 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change the text of a label?

#1
I have a radiobutton list and on click on the radio button item I have to change the text of its label. But for some reason it's not working. Code is below:

<!-- language: lang-html -->

<asp:Label ID="lblVessel" Text="Vessel:" runat="server"></asp:Label>

<script language="javascript">
$(document).ready(function() {

$('#rblDiv input').click(function() {
var selected = $("#rblDiv input:radio:checked").val();
if (selected == "exportpack") {
$('#lblVessel').text("NewText");
}
});
});
</script>
Reply

#2
ASP.Net [automatically generates unique client IDs for server-side controls](

[To see links please register here]

).

Change it to

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

In ASP.Net 4.0, you could also set the [`ClientIDMode` property](

[To see links please register here]

) to `Static` instead.
Reply

#3
Try this:

$('[id$=lblVessel]').text("NewText");

The `id$=` will match the elements that end with that text, which is how ASP.NET auto-generates IDs. You can make it safer using `span[id=$=lblVessel]` but usually this isn't necessary.
Reply

#4
I just went through this myself and found the solution. See an ASP.NET label server control *actually* gets redered as a span (not an input), so using the .val() property to get/set will not work. Instead you must use the 'text' property on the span in conjuntion with using the controls .ClientID property. The following code will work:

$("#<%=lblVessel.ClientID %>").text('NewText');
Reply

#5
I was having the same problem because i was using

$("#LabelID").val("some value");

I learned that you can either use the provisional jquery method to clear it first then append:

$("#LabelID").empty();
$("#LabelID").append("some Text");

Or conventionaly, you could use:

$("#LabelID").text("some value");
OR

$("#LabelID").html("some value");
Reply

#6
$('#<%= lblVessel.ClientID %>').html('New Text');


ASP.net Label will be rendered as a span in the browser. so user 'html'.
Reply

#7
we have to find label tag for attribute value based on that.we have replace label text.

Script:

<script type="text/javascript">
$(document).ready(function()
{
$("label[for*='test']").html("others");
});

</script>

Html

<label for="test_992918d5-a2f4-4962-b644-bd7294cbf2e6_FillInButton">others</label>

<a href="http://peakfinders.blogspot.in/2015/10/how-to-change-text-of-label.html"> You want to more details .Click Here</a>
Reply

#8
<asp:RadioButtonList ID="rbtnType" runat="server">
<asp:ListItem Value="C">Co</asp:ListItem>
<asp:ListItem Value="I">In</asp:ListItem>
<asp:ListItem Value="O">Out</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="lblLabelName" runat="server"></asp:Label>
<script type="text/javascript">
$(document).ready(function() {
$("#<%=rbtnType.ClientID%>").change(function() {
var rbvalue = $("input[@name=<%=rbtnType.ClientID%>]:radio:checked").val();
if (rbvalue == "C") {
$('#<%=lblLabelName.ClientID %>').html('text1');
} else if (rbvalue == "I") {
$('#<%=lblLabelName.ClientID %>').html('else text2');
} else if (rbvalue == "O") {
$('#<%=lblLabelName.ClientID %>').html('or elsethistext');
}
});
});
</script>
Reply

#9
try this

`$("label").html(your value);` or `$("label").text(your value);`

Reply

#10
lable value $('#lablel_id').html(value);
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through