0

Hi All,

Hi All, I'm in a bit of a pickle here. I'm Binding the name of file to a LinkButton and intending to open that file on the LinkButton' click. I have the LinkButton in the TemplateField of a GridView control. Below is the code I'm using :

<asp:TemplateField HeaderText="Article Name">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" ForeColor="LightYellow" Text='<%# Eval("caption") %>'
                                Width="494px" CommandName="goto" CommandArgument='<%# Eval("file_name") %>'></asp:LinkButton>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="White" />
                        <ItemStyle ForeColor="LightYellow" />
                    </asp:TemplateField>

And the Event Handler goes like :

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("goto"))
        {
            fileToOpen = e.CommandArgument.ToString();
            Response.Redirect(path + fileToOpen);
        }
    }

On clicking i get the above mentioned error 'Forbidden' from ASP Development Server 8.0.0.0

Edited by mike_2000_17: Fixed formatting

3
Contributors
7
Replies
8
Views
7 Years
Discussion Span
Last Post by inAweofOOP
0

Hi All,

Hi All, I'm in a bit of a pickle here. I'm Binding the name of file to a LinkButton and intending to open that file on the LinkButton' click. I have the LinkButton in the TemplateField of a GridView control. Below is the code I'm using :

<asp:TemplateField HeaderText="Article Name">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" ForeColor="LightYellow" Text='<%# Eval("caption") %>'
                                Width="494px" CommandName="goto" CommandArgument='<%# Eval("file_name") %>'></asp:LinkButton>
                        </ItemTemplate>
                        <HeaderStyle ForeColor="White" />
                        <ItemStyle ForeColor="LightYellow" />
                    </asp:TemplateField>

And the Event Handler goes like :

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("goto"))
        {
            fileToOpen = e.CommandArgument.ToString();
            Response.Redirect(path + fileToOpen);
        }
    }

On clicking i get the above mentioned error 'Forbidden' from ASP Development Server 8.0.0.0

Hi give the server username and password on Virtual directory of IIS. It will solve this issue. otherwise try to use inpersonation.

Edited by mike_2000_17: Fixed formatting

0

Hi murugavel84,
I tried impersonation its still not working..its giving the same error when i run it on my machine...but i put on my server and acces the link from browser it sayz page not found..what do i do....pls help..

0

Hi murugavel84,
I tried impersonation its still not working..its giving the same error when i run it on my machine...but i put on my server and acces the link from browser it sayz page not found..what do i do....pls help..

Can u please attach the error screenshot?

0

Instead of using Response.Redirect("Some file Name") using Response.WriteFile() method which writes the contents of the specified file directly to an HTTP response output stream as a file block. For example,

Response.WriteFile(@"D:\Temp\Test1.docx") ;
 //Response.WriteFile(path + fileToOpen);

Edited by Ramesh S: n/a

0

Here is the screenshot, sir..

-> Open IIS (Run->inetmgr)
-> Right click on your projects virtual directory and select Properties.
-> Select the Documents tab.
-> Click on the 'Add...' button.
-> Enter 'default.aspx' (without quotes) and click OK, then click OK back on the Properties dialog.

If u want to do it globally. Just set the same on website(Ex:DefaultWebsite).

This will solve this error. Otherwise let me know.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.