When I created a label I set it's display to none in the designer.
<asp:Label ID="label1" runat="server" style="display:none;" Text="LABEL" asp:Label>
I use javascript to turn the label visible by:
var lbl = document.getElementById('label1');
lbl.style.display="";
WHen I do this the space is created where the label would be on the form but the label itself doesn't show up. I have tried
lbl.style.display="inline";
lbl.style.display="block";
just to see if the label would show up. Still nothing though. Just the extra space where the label would be is created.
When I created a label I set it's display to none in the designer.
<asp:Label ID="label1" runat="server" style="display:none;" Text="LABEL" asp:Label>
I use javascript to turn the label visible by:
var lbl = document.getElementById('label1');
lbl.style.display="";
WHen I do this the space is created where the label would be on the form but the label itself doesn't show up. I have tried
lbl.style.display="inline";
lbl.style.display="block";
just to see if the label would show up. Still nothing though. Just the extra space where the label would be is created.
Share Improve this question edited Jan 4, 2011 at 18:40 Johnrad asked Jan 4, 2011 at 18:34 JohnradJohnrad 2,65518 gold badges62 silver badges102 bronze badges 5- Are you sure the element contains text? Is there any other style applied to the element? – Felix Kling Commented Jan 4, 2011 at 18:35
-
3
Shouldn't you be using
lbl.style.display="inline";
? – MooGoo Commented Jan 4, 2011 at 18:36 - Felix King - only other style applied is color. And The element does for sure have text – Johnrad Commented Jan 4, 2011 at 18:36
- I have done lbl.visibility = "hidden" but I don't much care for that because it still leaves the blank space. I like how lbl.display = "none" doesn't leave the blank space when the element is not being displayed. – Johnrad Commented Jan 4, 2011 at 18:43
- check the lable using firebug or similar tool. – Tasawer Khan Commented Jan 4, 2011 at 18:46
2 Answers
Reset to default 5You were saying
WHen I do this the space is created where the label would be on the form but the label itself doesn't show up. I have tried
That makes me believe that somewhere in your CSS you may have visibility
set to hidden
. That normally covers the space of the element, but doesn't show it. The display
controls whether or not the space is preserved for the element.
Are you certain you have the control ID correct? Unless you set ClientIDMode to Static, the actual control ID will probably be something much longer than the ID you specify. Check the control's ClientID property.