I can’t open my grid view link

Asked

Viewed 74 times

0

I made the following code

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="ID_PTD" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
        <Columns>
            <asp:BoundField DataField="CAMINHO" HeaderText="CAMINHO" SortExpression="CAMINHO" />
            <asp:BoundField DataField="NOME" HeaderText="NOME" SortExpression="NOME" />
            <asp:BoundField DataField="PROFESSOR" HeaderText="PROFESSOR" SortExpression="PROFESSOR" />
            <asp:BoundField DataField="ETEC" HeaderText="ETEC" SortExpression="ETEC" />
            <asp:BoundField DataField="DATA" HeaderText="DATA" SortExpression="DATA" />
            <asp:TemplateField HeaderText="Documentos">
            <EditItemTemplate>
                        <a ID="hpCaminho" class="materialize-textarea"  href ='<%# Bind("CAMINHO") %>' runat="server">Abrir</a>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <a ID="hpCaminho" class="materialize-textarea"  href ='<%# Bind("CAMINHO") %>' runat="server">Abrir</a>
                    </ItemTemplate>  
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

it runs smoothly in my visual studio however, when clicking on the grid view link nothing happens

inserir a descrição da imagem aqui

we can see that in the lower left corner it shows the way, but when I click open it does not open, why it does not open and how I can solve this

1 answer

1


You cannot open a local file on the user’s machine through a link, for security reasons this is blocked in most browsers

If you open the console, you will surely see an error similar to "Not allowed to load local resource"

What you can do is map this directory on your server and provide a relative path or, for example, create a method that will read this file in the physical path of the server and return the stream to the user for download.

  • if it was the case that my file was on the server, it will be able to open?

  • just tested with a file path . pdf online and it worked, when I pass my project to server it will occur all right, obg by help

Browser other questions tagged

You are not signed in. Login or sign up in order to post.