473,408 Members | 1,747 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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.

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
3 2396
Rabbit
12,516 Expert Mod 8TB
You need to escape the double quotes in your string.
Mar 5 '13 #2
One set of quotes is for the Response.Write and the other set is for the href tag.
Mar 5 '13 #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

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

Similar topics

4
by: dr. zoidberg | last post by:
Hello, I'm pulling news titles from MySQL. How Can I display first record in bold (different than other ones). What is the best way to do that. Is there some 'magic' query or PHP function. ...
1
by: simonmarkjones | last post by:
Hi there when i open a form in Access 2000 i would like to present the user with a new empty record (I dont want them to be able to view the first or any other records). I'm guessing i would put...
5
by: Ren | last post by:
Hello all, I have a page which can list all records from a table in my local database. For each record that is displayed there is link next to it. When the link is pressed another page opens...
2
by: bobh | last post by:
In Access97 on a bound form, client wants a button that will duplicate the currently displayed record and give it a new meeting nbr. I have done it except for being able to display the new record...
2
by: sheenaa | last post by:
Hi, I want to display the last recorded record in the database of SQL SERVER 2005. How can i display it with the select query in the grid view... The database contains the...
3
by: =?iso-8859-1?Q?Leentje=AE?= | last post by:
hi, i'm trying to determine if a record is empty and when it's not, it has to show that record to test, I put three X's in the code the content of rs("opmerking") isn't shown but the...
1
by: Coll | last post by:
Hi - I'm trying to figure out how to append a record to a table and then open a form and display that record. My thought was to use the autonum primary key field (recordnum) and display the highest...
6
by: Gilberto | last post by:
Hello I have a table (BOM TOTAL L1 V1) created by a query which only contains one field (TCL1) with ONE record. I've been trying to display this record on a form (either in a textbox or a label)...
21
by: postman | last post by:
I have a subform which is bound to a query which will display records using an ID# supplied from a listbox in the parent form. That same subform is also used to create new records using the...
5
by: saga git | last post by:
how to display nth record from table
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.