Advanced Search

Results 1 to 2 of 2

Thread: How to create link in asp

  1. #1
    Join Date
    Nov 2004
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to create link in asp

    I am using a event listing applicatio which has database running at backend. I have made the field "feature1" in db as hyperlink and its working fine but this field does not show up as hyperlink on the viewing page...what can I change so that it does come up as hyperlink....thanks

    I want the "contact" field to show up as hyperlink. the variable for it is Feature1
    http://www.aacps.org/development/development_alerts.asp


    The code in asp file for this is
    <% If eventlist.Fields.Item("Feature1").Value <> "" Then %>
    <tr>
    <td width="80" valign="top" class="tableheader"><div align="right">Contact: </div>
    </td>
    <td valign="top" bgcolor="#FFFFCC"><%=Replace(eventlist.Fields.Item("Feature1").Value,Chr(13),"<BR>")%></td>
    </tr>
    <% End If%>

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    You need to use Anchor tag whenever you create a link in HTML. Refer the following code piece

    Code:
    <%
    	Dim href
    	Dim title
    	
    	href = "http://www.google.com" 		'The url of the site
    	title = "Visit Google" 					' The title you want to use
    	
    	Response.Write("<a href='"& href &"' target='_blank'>" & title & "</a>")
    %>
    In the above code snippet you've stored the actual url in a variable href and the title you want to show in title variable. The Response.Write() does the hyperlink writing which is self explanatory.

    Code:
    <%
    	Dim href
    	Dim title
    	
    	href = "http://www.yahoo.com" 		'The url of the site
    	title = "Yahoo!" 					' The title you want to use
    
    	Dim hyperlink: hyperlink = "<a href='"& href &"' target='_blank'>" & title & "</a>" 	'complete anchor tag in a variable
    	
    	Response.Write("<br>"&hyperlink)	'Hyperlink construction
    %>
    In the above code snippet the variable part is almost similar in the first code snippet except a major difference, here we stored the entire anchor tag inside a variable and wherever we need the hyperlink we just used it using Response.Write()

    In your case you can retrieve the hyperlink (url) value from your database and specify that in place of the href attribute of anchor tag as well as if you want you can specify it as the caption of the anchor tag.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •