?
Solved

Using IIf with Server.Encode

Posted on 2000-03-12
4
Medium Priority
?
551 Views
Last Modified: 2008-02-20
I've got this line:
<TD BORDERCOLOR=#c0c0c0 width="645" ><font color="#000000" face="Verdana" size="1"><%=Server.HTMLEncode(rs.Fields("ProgTitle").Value)%></font></TD>

I need to add an IIf in there that says, "if the Value of the field is Null, then make it equal to " ", else make it equal to the Value."
0
Comment
Question by:EvanL
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
CoolAss earned 60 total points
ID: 2610711
Instead of:
<%=Server.HTMLEncode(rs.Fields("ProgTitle").Value)%>

Do this:

<%
if Len(rs.Fields("ProgTitle")) < 1 then
  Response.Write(" ")
else
  Response.Write(rs.Fields("ProgTitle"))
end if
%>

This could also go all on one line:

<%if Len(rs.Fields("ProgTitle")) < 1 then Response.Write(" ") else Response.Write(rs.Fields("ProgTitle")) end if%>



0
 
LVL 4

Expert Comment

by:CoolAss
ID: 2610712
BTW, if for some reason this data can be a zero length string, yet not be Null, use this:

<%if IsNull(rs.Fields("ProgTitle")) then Response.Write(" ") else Response.Write(rs.Fields("ProgTitle")) end if%>

But chances are, the first post is what you want.







0
 
LVL 1

Author Comment

by:EvanL
ID: 2611926
Thanks for the post.  I'll try this tonight when I get home from work and report findings back here.
0
 
LVL 1

Author Comment

by:EvanL
ID: 2638382
Sorry for the delay.  Had to go out-of-town unexpectedly.

This works great.  Thanks for the help.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question