Solved

asp.net VB creating hyperlinks

Posted on 2011-09-21
4
364 Views
Last Modified: 2012-06-22
I am trying to create a dynamic hyperlink in my asp.net document. The code I am using for the link part is:

<asp:HyperLink  
text="<%# Eval("doc_loc") %>"  
navigateurl="yourpath<%# Eval("doc_loc") %>"
target="_blank" />

but in the browser the asp:Hyperlink tag is being returned without conversion into html:
<asp:hyperlink text="Soccer0002.pdf" navigateurl="yourpathSoccer0002.pdf" target="_blank">
    </asp:hyperlink>

an example version of the page is here: http://shatterboxwebdesign.com/slsdelete/delete-preview.htm

and my full page code is attached. Can someone tell me what I am doing wrong here?

Thanks
<%@ Page Language="VB" MasterPageFile="~/admin_MasterPage.master" validateRequest="False" AutoEventWireup="false" CodeFile="admin_eenvelope_delete.aspx.vb" Inherits="admin_eenvelope_delete" title="" Debug="true" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    <script type="text/javascript">
if (document.images) {
    img1 = new Image();
    img1.src = "images/delete_button_on.png";
}
</script>
<script type="text/javascript" language="javascript">
function DeleteConfirmation()
{
if (confirm("Are you sure, you want to delete selected records ?")==true)
   return true;
else
   return false;
}
</script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Label ID="Message" runat="server" Text=""></asp:Label>

    <span class="style1">Delete eEnvelope Items</span><br /><br />
    <div align="center">
<asp:GridView ID="GridView1" runat="server" 
              AutoGenerateColumns="False" 
              DataSourceID="SqlDataSource1" 
              ShowFooter="true">
     <Columns>
     <asp:TemplateField HeaderText="Delete?" ShowHeader="true" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="80px" ItemStyle-HorizontalAlign="Center">
     <ItemTemplate>
     <asp:CheckBox ID="chkSelect" runat="server" />
     </ItemTemplate>
     <FooterTemplate>
        <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/images/delete_button_off.png" OnClick="btnDelete_Click" OnClientClick="return DeleteConfirmation();"/>
     <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $('#ctl00_ContentPlaceHolder1_GridView1_ctl03_btnDelete').hover(
            function(){ // Change the input image's source when we "roll on"
                $(this).attr({ src : 'images/delete_button_on.png'});
            },
            function(){ // Change the input image's source back to the default on "roll off"
                $(this).attr({ src : 'images/delete_button_off.png'});             }
        );
    });
</script>
      </FooterTemplate>
      </asp:TemplateField>
      <asp:BoundField DataField="id" 
                      HeaderText="ID" 
                      SortExpression="id"
                      HeaderStyle-Width="200px" 
                      ItemStyle-HorizontalAlign="Center" />
     

<asp:TemplateField HeaderText="Document" >
     <ItemTemplate>
<asp:HyperLink   
text="<%# Eval("doc_loc") %>"  
navigateurl="yourpath<%# Eval("doc_loc") %>" 
target="_blank" />

    </ItemTemplate>
</asp:TemplateField>




      </Columns>
     
     <HeaderStyle BackColor="#99CCFF" />
     
     <AlternatingRowStyle BackColor="#99CCFF" Wrap="False" />
</asp:GridView>
</div>
    <br />
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
  ConnectionString="<%$ ConnectionStrings:stluke %>"
     SelectCommand="SELECT [id], [doc_loc] FROM [elliott_tod10].[eenvelope]"></asp:SqlDataSource>
<br />
<br />
    <%-- %><asp:ImageButton id="btnDelete" runat="server" ImageUrl="~/images/delete_event_off.png" OnClick="btnDelete_Click" />
    <script type="text/javascript" charset="utf-8">
    $(document).ready(function(){
        $('#ctl00_ContentPlaceHolder1_ImageButton1').hover(
            function(){ // Change the input image's source when we "roll on"
                $(this).attr({ src : 'images/delete_event_on.png'});
            },
            function(){ // Change the input image's source back to the default on "roll off"
                $(this).attr({ src : 'images/delete_event_off.png'});             }
        );
    });
</script> --%>
    <br />

<%-- <input type="image" name="add_event" id="add_event" src="images/add_event_off.png" runat="server"> --%>
		
</asp:Content>

Open in new window

0
Comment
Question by:elliottbenzle
4 Comments
 
LVL 15

Accepted Solution

by:
pateljitu earned 250 total points
ID: 36573976
Add  runat="server", please try code:

<asp:HyperLink  
text="<%# Eval("doc_loc") %>"  
navigateurl="yourpath<%# Eval("doc_loc") %>"
target="_blank"  runat="server"  />
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 36575859
What is "yourpath"?
Check if this link helps.
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 36576190
May be

<asp:HyperLink  
text="<%# Eval("doc_loc") %>"  
navigateurl="<%# Server.MapPath(Eval("doc_loc")) %>"
target="_blank" />


Or you may want to concatenate path such as

<asp:HyperLink  
text="<%# Eval("doc_loc") %>"  
navigateurl="<%# Server.MapPath("/Files/" & Eval("doc_loc")) %>"
target="_blank" />
0
 
LVL 4

Author Closing Comment

by:elliottbenzle
ID: 36577096
Thanks
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to sort a list of objects using an item in an enclosed list 5 46
Regex validation 2 24
performance issue in asp web 5 32
List<PaisEntity> - show some 1 24
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question