473,396 Members | 2,154 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.

Conditional coding

Hi

On a webform I need some links to appear only if some condition is met.
Basically I am looking for something like this;

if x=y then
<-- generate html to display the relevant link 1-->
end if

if a=b then
<-- generate html to display the relevant link 2-->
end if

Could someone please provide a link to such an example?

Thanks

Regards
Dec 18 '05 #1
6 1147
Make the links to server HyperLinks controls. Set their Visible property
like this:
myLink1.Visible = (x=y)

Eliyahu

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi

On a webform I need some links to appear only if some condition is met.
Basically I am looking for something like this;

if x=y then
<-- generate html to display the relevant link 1-->
end if

if a=b then
<-- generate html to display the relevant link 2-->
end if

Could someone please provide a link to such an example?

Thanks

Regards

Dec 18 '05 #2
Forgot to mention. Likely, you will want to do it in the Page_Load event. If
the conditions are in the data sources you are binding to, you will want to
use either ItemDataBound or PreRender event.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
Make the links to server HyperLinks controls. Set their Visible property
like this:
myLink1.Visible = (x=y)

Eliyahu

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi

On a webform I need some links to appear only if some condition is met.
Basically I am looking for something like this;

if x=y then
<-- generate html to display the relevant link 1-->
end if

if a=b then
<-- generate html to display the relevant link 2-->
end if

Could someone please provide a link to such an example?

Thanks

Regards


Dec 18 '05 #3
Works nicely except there are <br>s between each linkbutton and when a
linkbutton is not visible the space is still there giving away the fact that
something is missing. How can I get rid of extra space around a link when
the link is not visible?

Thanks

Regards

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uF**************@TK2MSFTNGP14.phx.gbl...
Forgot to mention. Likely, you will want to do it in the Page_Load event.
If the conditions are in the data sources you are binding to, you will
want to use either ItemDataBound or PreRender event.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
Make the links to server HyperLinks controls. Set their Visible property
like this:
myLink1.Visible = (x=y)

Eliyahu

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi

On a webform I need some links to appear only if some condition is met.
Basically I am looking for something like this;

if x=y then
<-- generate html to display the relevant link 1-->
end if

if a=b then
<-- generate html to display the relevant link 2-->
end if

Could someone please provide a link to such an example?

Thanks

Regards



Dec 18 '05 #4
John,

Use a literal control instead of the hyperlink. The literal control can be
filled with whatever you want and the text inside it will be rendered
without change. Just drop the literal control on the page where you need it
and then use a string builder to create your links like this:

Dim MyStringBuilder As New System.Text.StringBuilder

If x=y Then
MyStringBuilder.Append("<a href=www.msn.com
target=_blank>www.msn.com</a>")
End If

If a=b Then
MyStringBuilder.Append("<a href=www.msn.com
target=_blank>www.msn.com</a><br>")
End If

Literal1.Text = MyStringBuilder.ToString

This way you'll be able to control when you need a break or not.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:uw****************@TK2MSFTNGP12.phx.gbl...
Works nicely except there are <br>s between each linkbutton and when a
linkbutton is not visible the space is still there giving away the fact
that something is missing. How can I get rid of extra space around a link
when the link is not visible?

Thanks

Regards

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uF**************@TK2MSFTNGP14.phx.gbl...
Forgot to mention. Likely, you will want to do it in the Page_Load event.
If the conditions are in the data sources you are binding to, you will
want to use either ItemDataBound or PreRender event.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
Make the links to server HyperLinks controls. Set their Visible property
like this:
myLink1.Visible = (x=y)

Eliyahu

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi

On a webform I need some links to appear only if some condition is met.
Basically I am looking for something like this;

if x=y then
<-- generate html to display the relevant link 1-->
end if

if a=b then
<-- generate html to display the relevant link 2-->
end if

Could someone please provide a link to such an example?

Thanks

Regards



Dec 18 '05 #5
How did the <br>s get there in the first place? Must be from your layout.
Look at the layout, find what generates them and delete the source. You
might want to layout the page with html tables.

Eliyahu

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:uw****************@TK2MSFTNGP12.phx.gbl...
Works nicely except there are <br>s between each linkbutton and when a
linkbutton is not visible the space is still there giving away the fact
that something is missing. How can I get rid of extra space around a link
when the link is not visible?

Thanks

Regards

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:uF**************@TK2MSFTNGP14.phx.gbl...
Forgot to mention. Likely, you will want to do it in the Page_Load event.
If the conditions are in the data sources you are binding to, you will
want to use either ItemDataBound or PreRender event.

Eliyahu

"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:u9**************@TK2MSFTNGP11.phx.gbl...
Make the links to server HyperLinks controls. Set their Visible property
like this:
myLink1.Visible = (x=y)

Eliyahu

"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi

On a webform I need some links to appear only if some condition is met.
Basically I am looking for something like this;

if x=y then
<-- generate html to display the relevant link 1-->
end if

if a=b then
<-- generate html to display the relevant link 2-->
end if

Could someone please provide a link to such an example?

Thanks

Regards



Dec 18 '05 #6
"John" <Jo**@nospam.infovis.co.uk> wrote in
news:uw**************@TK2MSFTNGP12.phx.gbl:
Works nicely except there are <br>s between each linkbutton and
when a linkbutton is not visible the space is still there giving
away the fact that something is missing. How can I get rid of
extra space around a link when the link is not visible?


John,

You could put the link button and <br> in a panel, and then set the
panel's visibility.
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Dec 18 '05 #7

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

Similar topics

28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
13
by: Andrew | last post by:
I use conditional compiler constants, set through the VBA IDE in Tools, <projectname> Properties, that I refer to throughout my code to control which code is used during development, and which...
10
by: nimmi_srivastav | last post by:
Below you will see an example of a nested conditional expression that this colleague of mine loves. He claims that it is more efficient that a multi-level if-else-if structure. Moreover, our...
6
by: Robert Zurer | last post by:
In his paper on Coding Standard found on http://www.idesign.net/idesign/DesktopDefault.aspx Juval Lowy discourages the use of the ternary conditional operator with no specific reason given. ...
2
by: Lionel B | last post by:
I frequently seem to run into the following annoyance regarding template class specialisation: I have a template class which implements, for a general template parameter, some basic functionality...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...

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.