0

Im wrkng on a small project Im creating a web app which consists of

NAME  
EMAIL           
AGE               
PHONENO 
Fileupload(toolbox)
showFile(Hyperlink)

after user entering the data above and upoaded the file when he clicks on the ShowFile link the page shoul dispaly the pdf file and uploaded file can any 1 help me with this

i had succeded upto upoad file

protected void Page_Load(object sender, EventArgs e)
{


}
protected void Button1_Click(object sender, EventArgs e)
{

    if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0))
    {
        string fn = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
        string SaveLocation = Server.MapPath(".") + "\\" + fn;
        try
        {
            FileUpload1.PostedFile.SaveAs(SaveLocation);
            Label6.Text = "File Uploaded Successfully...";
        }
        catch (Exception ex)
        {
            Response.Write("Error: " + ex.Message);

        }
    }
    else
    {

     Label6.Text = "Upload .pdf File";

    }
}
 }
Ni Ru
  • 88
  • 1
  • 1
  • 7

1 Answers1

0

in my opinion the simplest way to explain how to get data on another page is to send parameters in querystring like:

protected void Page_Load(object sender, EventArgs e)
{


}
protected void Button1_Click(object sender, EventArgs e)
{
//your code here
string fileName =FileUpload1.PostedFile.FileName;
string url = string.Format("~/nameOfAnotherPage.aspx?parameter1={0}&parameter2={1}&filename={2}",Label1.Text, Label2.Text, fileName);
Response.Redirect(url);
}

On another page named in the example as "nameOfAnotherPage.aspx":

protected void Page_Load(object sender, EventArgs e)
 {
    if (!string.IsNullOrEmpty(Request.QueryString["parameter1"]))
    {
    string parameter1 = Request.QueryString["parameter1"] ;
    }   
    if (!string.IsNullOrEmpty(Request.QueryString["parameter2 "]))
    {
    string parameter2 = Request.QueryString["parameter2 "] ;
    }  
    if (!string.IsNullOrEmpty(Request.QueryString["filename"]))
    {
    string filename= Request.QueryString["filename"];
    }
Label1.Text = parameter1;
Label2.Text = parameter2;
}

About saving files from server to client this thread. You should try to learn programming from books, many of them you can find on amazon or wrox with tags like: asp.net, c#, programming.

Hope it helps

Community
  • 1
  • 1
Mariusz
  • 3,054
  • 2
  • 20
  • 31
  • when i click the show file option it should direct me to the page where uploaded file has saved – Ni Ru Dec 07 '11 at 09:22
  • But what do you want to do with that file? When you are uploading it to the server it is saved phisically on your machine. Show file link can redirect you to another page which will show you button. With that button you will be able to download file. Did I understand you wrong? – Mariusz Dec 07 '11 at 09:30
  • when i click on the ShowFile link it has to show the uploaded file in a new page...what should i do – Ni Ru Dec 07 '11 at 09:47
  • What do you mean by "show". You want to explore entire document which will be uploaded on the server? Or you want to show if it is uploaded like with icon and file name and with "download" button? – Mariusz Dec 07 '11 at 09:54
  • explore the entire document which is uploaded on the server – Ni Ru Dec 07 '11 at 10:46
  • [here](http://stackoverflow.com/questions/291813/best-way-to-embed-pdf-in-html) is some solution for showing pdf files, but I can't answer to your question then. – Mariusz Dec 07 '11 at 10:55