Solved

Using IIf with Server.Encode

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dreamweaver server behavior gone 6 148
API not working 33 67
Summernote required 3 187
return false must be hit after calling certain command 10 33
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 information …
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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