0

I am setting value of asp:label in JavaScript but it is blank on server side on button click.

what can be the issue?

pb2q
  • 58,613
  • 19
  • 146
  • 147
Sami
  • 3,956
  • 9
  • 37
  • 52
  • possible duplicate of [Set Text property of asp:label in Javascript PROPER way](http://stackoverflow.com/questions/10128530/set-text-property-of-asplabel-in-javascript-proper-way) – jbabey Oct 10 '12 at 13:02
  • The issue could be in your code.. Could you share the relevant part of it? – Michal Klouda Oct 10 '12 at 13:02

2 Answers2

2

Using jQuery:

$("#<%= label1.ClientID%>").text("SetYourTextHere");

Using javascript:

document.getElementById("<%= label1.ClientID%>").innerHTML = "SetYourTextHere";
Kapil Khandelwal
  • 15,958
  • 2
  • 45
  • 52
0

I assume ( you should show what you've tried ) that you've used the value attribute.

Use innerHTML instead. A SPAN does not have a value attribute.

var lbl = document.getElementById("Label1");
lbl.innerHTML = "Hello World";
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939