Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Needs Help with IIf Statement
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Needs Help with IIf Statement

 Post Reply Post Reply
Author
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Topic: Needs Help with IIf Statement
    Posted: 29 January 2005 at 3:28pm
I need help with an IIF statement in ASP.Net.
 
The line of code:  <%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099><b>Name:</FONT></b>&nbsp;<a href='mailto:" & Container.DataItem("Email") & "'>" & Container.DataItem("Name") & "</a>", "") %> works fine.
 
However, I would like to be able to display the name without being hyperlinked to an email address.
 
I tried the following line of code: <%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099>Name:</FONT>&nbsp;<FONT face=sans-serif>& Container.DataItem("Name") & "</font>", "")%>
 
This is the line of code I need help with. It's a problem with the syntax. Please look at the red part.
 
Here's a copy of the error message that I got on that line:
Compiler Error Message: BC30455: Argument not specified for parameter 'FalsePart' of 'Public Function IIf(Expression As Boolean, TruePart As Object, FalsePart As Object) As Object'.

Source Error:

Line 160:            <tr valign="top"> 
Line 161:         <td> <%# IIF(Container.DataItem("PublicEmail") = True,"<p><font face=sans-serif color=#330099><b>Name:</FONT></b>&nbsp;<a href='mailto:" & Container.DataItem("Email") & "'>" & Container.DataItem("Name") & "</a>", "") %>
Line 162:             <%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099>Name:</FONT>&nbsp;<FONT face=sans-serif>& Container.DataItem("Name") & "</font>", "")%>
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2005 at 3:49pm
<%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099>Name:</FONT>&nbsp;<FONT face=sans-serif>" & Container.DataItem("Name") & "</font>", "")%>
Back to Top
Misty View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 February 2002
Location: United States
Status: Offline
Points: 711
Post Options Post Options   Thanks (0) Thanks(0)   Quote Misty Quote  Post ReplyReply Direct Link To This Post Posted: 29 January 2005 at 8:41pm
Mart,
 
Thanks! I just missed one ". That's why I got the error message.
 
I have a question. Does anyone know if you can use else statements in ASP.Net or not? I have never seen else statements in ASP.Net before. I often use else statements in ASP.
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post Posted: 30 January 2005 at 3:43am
Yes, of course you can, you can do

If [Boolean] Then
'true condition
Else
'false condition
End If
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.