Click here to Skip to main content
15,905,874 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
I have 2 link button. My code which is working:
C#
protected void LinkButton1_Click(object sender, EventArgs e)
        {
            myframe.Attributes["src"] = "LINQToSQLCheatSheet.pdf";
        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            myframe.Attributes["src"] = "20120517110052.pdf";
        }


ASP.NET
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Pdf 1</asp:LinkButton>  
<asp:LinkButton ID="LinkButton2" runat="server" onclick="LinkButton2_Click">pdf 2</asp:LinkButton>
<div style="width:100%; height:850px">
<iframe id="myframe" width="100%" height="100%" runat="server"></iframe>


But, when I am keeping these 2 pdf files in a folder than this is not working. My code after putting pdf files in a folder:
C#
protected void LinkButton1_Click(object sender, EventArgs e)
       {
           myframe.Attributes["src"] = "Folder:\\LINQToSQLCheatSheet.pdf";
       }

       protected void LinkButton2_Click(object sender, EventArgs e)
       {
           myframe.Attributes["src"] = "Folder:\\20120517110052.pdf";
       }


Now, Im getting a error message:
" Firefox doesn't know how to open this address, because the protocol (folder) isn't associated with any program.

You might need to install other software to open this address."

I have tried it in another process as like this:
C#
protected void LinkButton1_Click(object sender, EventArgs e)
        {
            myframe.Attributes["src"] = "\Folder:\\LINQToSQLCheatSheet.pdf.pdf";
        }

        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            myframe.Attributes["src"] = "\Folder:\\20120517110052.pdf.pdf";
        }

Now getting another error:
"Unrecognized scape sequence"

Now, can anybody help me by solving this problem as I have to show those pdf file from a Folder or another directory.
Posted
Updated 4-Aug-12 21:14pm
v2

You need to put a \ in the start of the path, in order for it to find the file.
 
Share this answer
 
Comments
UL UL ALBAB 5-Aug-12 2:55am    
this folder is in the start-up path where my application is running.
Christian Graus 5-Aug-12 2:55am    
Did you do what I said ? I'm sure that's where it is, but a URL to a folder should start with a \.
UL UL ALBAB 5-Aug-12 2:57am    
yes. but, an error occurred :
Server Error in '/' Application.
HTTP Error 400 - Bad Request.
UL UL ALBAB 5-Aug-12 3:08am    
Do you mean to follow as like this: "\Folder:\\LINQToSQLCheatSheet.pdf" ? than got another error: Unrecognized escape sequence ..
Christian Graus 5-Aug-12 3:11am    
It's like you have no idea what you're doing. You have \\ to get a \ in the path later on, why did you think the same rules did not apply now ? I apologise for thinking you had some clue what this code did. "\\Folder:\\LINQToSQLCheatSheet.pdf"
Use '@' at the start of your Path,and after that give your whole path;
Like
myframe.Attributes["src"] = @"Folder:\20120517110052.pdf";

Try this.
 
Share this answer
 
Comments
UL UL ALBAB 5-Aug-12 3:34am    
This not working yet:
The address wasn't understood







Firefox doesn't know how to open this address, because the protocol (folder) isn't associated with any program.
Mohd Imran Saifi 5-Aug-12 3:53am    
myframe.Attributes["src"] = @"abc\\pdf2.pdf";
where abc is a folder name located on the webapplication

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900