Solved

Using IIf with Server.Encode

Posted on 2000-03-12
4
545 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
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
CoolAss earned 15 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now