Print Page | Close Window

If RecordField is empty then goto...

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=1023
Printed Date: 28 March 2026 at 11:06pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: If RecordField is empty then goto...
Posted By: Arguich811
Subject: If RecordField is empty then goto...
Date Posted: 14 March 2003 at 5:58pm

Hello,

I use the following method to get the hyperlinks from a recordfield in a database written into my page:
...
Response.Write ("<a class='b' href='" & rsQuery("pub_url") & "' target='_blank'>")Response.Write (".&nbsp;<i>" & rsQuery("title") & "</a></i>.&nbsp;")
...
In some cases however, there is no hyperlink, i.e.: the recordfield ('pub_url') is empty.  In that case, I want to the 'empty string' to be replaced by a link to a 'redirection-page', similar to a custom 404 page, so something like:

If rsQuery("pub_url") = empty then rsQuery("pub_url") = "redirect.htm"

However, I do not know how to do this.

anyone got an idea?

Armand




Replies:
Posted By: Gullanian
Date Posted: 14 March 2003 at 6:06pm

<%
IF isNull(rsQuery("pub_url")) or rsQuery("pub_url") = "" THEN
str_page = "redirect.htm"
else
str_page = rsQuery("pub_url")
end if
%>


<a href="<%=str_page%>">click</a>



Posted By: Arguich811
Date Posted: 14 March 2003 at 6:47pm

Thanks for this quick reply,

I translated your suggestion into:

...
Dim str_page
IF isNull(rsQuery("pub_url")) or rsQuery("pub_url") = "" THEN
str_page = "redirect.htm"
else
str_page = rsQuery("pub_url")
end if
...


...
Response.Write ("<a class='b' href='" &  str_page & "' target='_blank'>")
Response.Write (".&nbsp;<i>" & rsQuery("title") & "</a></i>.&nbsp;")
...

But this doesn't work because it writes the same fieldvalue for rsQuery in each record. I'm  probably still doing something wrong, but what?

Armand



Posted By: Arguich811
Date Posted: 14 March 2003 at 7:02pm

Sorry,

My mistake: I placed your script ABOVE the statement:

Do While not rsQuery.EOF

So obviously the code did not run. Thanks again, for your help.

 

Armand




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net