473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Boolean Visible Property problem

Hi

I'm new to asp.net and c# and I've got stuck on an apparently simple
problem:

I'm trying to make a HyperLink dynamically visible/invisible.

This is the HTML:

<asp:HyperLink Runat="server" Text="Back"
NavigateUrl='HeadingList.aspx' Visible='<%=isNotTop()%>' />

This is the in the .cs file:
public string isNotTop()
{
return ("false");
}
I get the error message:
<%=isNotTop()%> is not a valid value for Boolean.

I've tried getting isNotTop() to return a boolean but it doesn't help.

I've done something similar within a DataList using <%#...%> and it's
worked OK.

Can someone guide me in the right direction here?
Cheers
John South
Pangbourne UK
Nov 16 '05 #1
2 8077
Hi John,

Yes it would be much better to bind the Visible property to your function by
using the
<%#...%> construct:

<asp:HyperLink Runat="server" Text="Back"
NavigateUrl='HeadingList.aspx' Visible='<%# isNotTop()%>' />

and make sure isNotTop() returns a Boolean value.

You will have to call DataBind() on that control though
to make it work.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"John South" <js****@cix.co.uk> wrote in message
news:d2**************************@posting.google.c om...
Hi

I'm new to asp.net and c# and I've got stuck on an apparently simple
problem:

I'm trying to make a HyperLink dynamically visible/invisible.

This is the HTML:

<asp:HyperLink Runat="server" Text="Back"
NavigateUrl='HeadingList.aspx' Visible='<%=isNotTop()%>' />

This is the in the .cs file:
public string isNotTop()
{
return ("false");
}
I get the error message:
<%=isNotTop()%> is not a valid value for Boolean.

I've tried getting isNotTop() to return a boolean but it doesn't help.

I've done something similar within a DataList using <%#...%> and it's
worked OK.

Can someone guide me in the right direction here?
Cheers
John South
Pangbourne UK


Nov 16 '05 #2
HI John

You are mixing the old ASP model with the new one :)

You have two options, you can set it in the code simply using an assignment
like
theHyperLink.Visible = false;
you can do this from anywhere in the code behind.

You can use the DataBind mechanist, for this you have to change the <%= %>
tag for <%# %>
Please make note that it's a complete new feature !!
if so you have to change the type of the function to the correct type of
the Visible property:
public bool isNotTop()
{
return false;
}
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"John South" <js****@cix.co.uk> wrote in message
news:d2**************************@posting.google.c om...
Hi

I'm new to asp.net and c# and I've got stuck on an apparently simple
problem:

I'm trying to make a HyperLink dynamically visible/invisible.

This is the HTML:

<asp:HyperLink Runat="server" Text="Back"
NavigateUrl='HeadingList.aspx' Visible='<%=isNotTop()%>' />

This is the in the .cs file:
public string isNotTop()
{
return ("false");
}
I get the error message:
<%=isNotTop()%> is not a valid value for Boolean.

I've tried getting isNotTop() to return a boolean but it doesn't help.

I've done something similar within a DataList using <%#...%> and it's
worked OK.

Can someone guide me in the right direction here?
Cheers
John South
Pangbourne UK

Nov 16 '05 #3

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

Similar topics

1
by: mike | last post by:
Hi, I'd like advice from a .NETer. I have a loadcombo routine which sets the selectedindex to -1 if it's an "add record", but then it goes to a security routine which, based on permissions...
5
by: Lucvdv | last post by:
Can anyone explain why this happens with the code at the bottom? It looked like a thread safety issue, but changing the declaration of Label1 to Shared doesn't help. Standard windows form;...
6
by: Marc Robitaille | last post by:
Hello, Hello, I developed a UserControl. It has funny behavior. It is composed of three controls. A texbox, a combobox and a button. There are three properties to indicate the visibility of...
6
by: Robert | last post by:
Quick question about the visible property on a form control. I have a label that displays a message if a certain criteria is met. By default the label is visible. I want access to compare a...
2
by: Keithb | last post by:
I need to hide a GridView's "edit" column if the user's role does not support editing. However, the column's Visible property does not support databinding. Is there a workaround? Thanks, ...
0
by: landesjoe | last post by:
Hi, here's my problem in short: Text boxes in gridview don't seem to hold their value if the column's .Visible property is changed back and forth. I've got a form with a gridview populated from...
8
by: Doc John | last post by:
I have an MDI container with a child Form which will be visible according to certain events. The problem is that when I set the property Visible to False and then back to True, the Form will be in...
5
by: =?Utf-8?B?VGVycnk=?= | last post by:
Hi, I have a couple of labels on a form and their visible property is bound to boolean properties on a custom object. When I first load the form, all works as it should. This form is 'tied'...
6
by: MLH | last post by:
I have a small bitmap graphic on a report. I would like to set it's Visible property to True whe the value of a certain field on the report is True. Can I do that? I have tried in the OnFormat...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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,...

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.