473,474 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Hiding a label

Bob Ross
119 New Member
I want a hidden label on my page that becomes visible if cookies are not enabled.
Now I have javascript to test cookie and change the labels visibility property, but If I set the label to not visible in .net then it does not build the label at all. I have to use an asp:label (instead of a normal html label) because of translation issues.

Is there a way I can get it to build a label and not show until javascript changes something?
Feb 15 '07 #1
3 1173
chazcross
31 New Member
Then dont hide the label in .net
use inline css
add this tag to the label

style="display:none;"


and then use js to change it to display:block

Expand|Select|Wrap|Line Numbers
  1. document.getElementById("elementnamehere").style.display = "block";
Feb 15 '07 #2
Frinavale
9,735 Recognized Expert Moderator Expert
Hi there!

Chazcross is right.

When you hide a label using the server side code in .NET, the element is never written to the page (thus it is more than invisible, its not there).

By setting the label's "style=display:none" instead, the label is still present on the web page but simply isn't displayed. Then when your JavaScript detects that your Cookies are disabled you can just set the label's style to be "style=display:block" or inline or whatever you would like.

When you want to access the label using JavaScript, you can do so by using the following:
document.getElementById('labelName').style.display ='inline';

Just remember that if you are using this label for other things (like displaying all of your errors or something), that this variable is invisible by default. You'll have to set the display value back every time you want to use it.

I'd just keep one label for the Cookies error message and use separate labels for displaying other error messages to avoid this kind of mess.

Cheers!

-Frinny
Feb 15 '07 #3
Bob Ross
119 New Member
I have got it working just the way I want it.

Thanks very much to the both of you.
Feb 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: c.anandkumar | last post by:
Hi All - I have some problems getting a small piece of javascript working correctly for Firefox. Here is what I am trying to do - 1. I have a form (like a search form) 2. I have many groups...
1
by: Howie | last post by:
Hi I'm producing a Report of electrical devices tested during a long job. I have a Sub report of Devices inspected visually. If there are no devices with problems the Sub report is Blank with just...
7
by: Baski | last post by:
Base class: class AssetBase { string _clli; public string CLLI { get
9
by: tshad | last post by:
I have a datagrid that I want to add a new column to. This column will only be visible under certain conditions. So I want to set the column visible=false. Then when the right condition happens...
3
by: sloan | last post by:
<asp:BoundField DataField="MyDate" DataFormatString="{0:d}" HeaderText="My Date" /> I have a BoundField being populuated with the "MyDate" column. The MyDate is in a strongly typed DataSet. The...
2
by: Coll | last post by:
I have a field that I would like to display on a report only if the value of another field matches a certain criteria. If it does match I need the label & the field value to display (though I'm...
0
by: Frank | last post by:
Hi, I have read the other post about hiding the updatepanel using the ajax lifecycle as such at the end of the aspx page: <script type="text/javascript" language =javascript> var c = new...
11
by: JJ297 | last post by:
I want to hide the Pin field below in my repeater. How do I do this? <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1"> <ItemTemplate> <tr> <td><font...
0
by: bharathreddy | last post by:
Hi All, I am using a listview control in my usercontrol so that it can be used in more than one form. This user control has one column extraw, so i want to make it invisible depending on the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.