By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,162 Members | 1,066 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,162 IT Pros & Developers. It's quick & easy.

How to display something if a record set is not empty?

P: 3
I have an unordered list on my ASP VBScript page. Basically, I want to do this:

IF record set is not empty THEN
show News button
ELSE
do not show News button

I want the News button to display as a list item.

I have code working to check if a record set is empty or not and I'm using Response.Write, which is probably a problem.

Expand|Select|Wrap|Line Numbers
  1. <% If (rsNews.EOF=False) Then
  2.           Response.Write("<li><a href="newspage.asp?Dir_ID=<%=(rsDirectory.Fields.Item("Dir_ID").Value)%>">News</a></li>")
  3. %>      
  4. <% End If %>

Is this possible? Can/should I use something other than Response.Write?
Mar 5 '13 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,369
You need to escape the double quotes in your string.
Mar 5 '13 #2

P: 3
One set of quotes is for the Response.Write and the other set is for the href tag.
Mar 5 '13 #3

P: 3
it can be done without response.write, and single quotes in the <a href> tag. this works:

Expand|Select|Wrap|Line Numbers
  1. <% If (rsNews.EOF=False) Then %>
  2.   <li><a href='newspage.asp?Dir_ID=<%=(rsDirectory.Fields.Item("Dir_ID").Value)%>'>News</a></li>
  3. <% End If %>
Mar 5 '13 #4

Post your reply

Sign in to post your reply or Sign up for a free account.