Solved

Using IIf with Server.Encode

Posted on 2000-03-12
4
549 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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
File download script VBSCRIPT fail on download PPT files 2 76
Hide cell in a table 2 42
Html CheckBox obtain Its Value 5 43
PHP $_POST vs asp request 4 56
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
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/…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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