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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JoeMayo
    New Member
    • Mar 2013
    • 3

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

    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.

    Code:
    <% If (rsNews.EOF=False) Then
              Response.Write("<li><a href="newspage.asp?Dir_ID=<%=(rsDirectory.Fields.Item("Dir_ID").Value)%>">News</a></li>")
    %>	  
    <% End If %>

    Is this possible? Can/should I use something other than Response.Write?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You need to escape the double quotes in your string.

    Comment

    • JoeMayo
      New Member
      • Mar 2013
      • 3

      #3
      One set of quotes is for the Response.Write and the other set is for the href tag.

      Comment

      • JoeMayo
        New Member
        • Mar 2013
        • 3

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

        Code:
        <% If (rsNews.EOF=False) Then %>
          <li><a href='newspage.asp?Dir_ID=<%=(rsDirectory.Fields.Item("Dir_ID").Value)%>'>News</a></li>
        <% End If %>

        Comment

        Working...