在复制一个Web应用程序进入到一个单独的页面的数据? [英] Copy the data entered in a web app to a separate page?

查看:130
本文介绍了在复制一个Web应用程序进入到一个单独的页面的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

林wrkng上的一个小项目
 进出口创建一个Web应用程序,下设

  NAME
电子邮件
年龄
电话号码
文件上传(工具箱)
演出文件(超链接)

在用户输入以上数据和upoaded文件时,他点击了链接演出文件的页面建议立即进行删除dispaly PDF文件并上传的文件可在任何1帮助我

我已经succeded高达upoad文件

 保护无效的Page_Load(对象发件人,EventArgs的发送)
{
}
保护无效的button1_Click(对象发件人,EventArgs的发送)
{    如果((FileUpload1.PostedFile = NULL)及!及(FileUpload1.PostedFile.ContentLength大于0))
    {
        字符串FN = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
        串SaveLocation =使用Server.Mappath(。)+\\\\+ FN;
        尝试
        {
            FileUpload1.PostedFile.SaveAs(SaveLocation);
            Label6.Text =文件成功上载...;
        }
        赶上(异常前)
        {
            的Response.Write(错误:+ ex.Message);        }
    }
    其他
    {     Label6.Text =上传.pdf文件;    }
}
 }


解决方案

在我看来,解释如何得到另一页上的数据最简单的方法是在查询字符串例如发送参数:

 保护无效的Page_Load(对象发件人,EventArgs的发送)
{
}
保护无效的button1_Click(对象发件人,EventArgs的发送)
{
//你的code在这里
字符串文件名= FileUpload1.PostedFile.FileName;
字符串的URL = string.Format(\"~/nameOfAnotherPage.aspx?parameter1={0}&parameter2={1}&filename={2}\",Label1.Text, Label2.Text,文件名);
的Response.Redirect(URL);
}

在在本例中为nameOfAnotherPage.aspx命名的另一页:

 保护无效的Page_Load(对象发件人,EventArgs的发送)
 {
    如果(!string.IsNullOrEmpty(的Request.QueryString [参数1]))
    {
    字符串参数1 =的Request.QueryString [参数1];
    }
    如果(!string.IsNullOrEmpty(的Request.QueryString [参数2]))
    {
    字符串参数2 =的Request.QueryString [参数2];
    }
    如果(!string.IsNullOrEmpty(的Request.QueryString [文件名]))
    {
    字符串文件名=的Request.QueryString [文件名];
    }
Label1.Text =参数1;
Label2.Text =参数;
}

关于服务器将文件保存到客户端此<一个href=\"http://stackoverflow.com/questions/873207/force-download-of-a-file-on-web-server-asp-net-c-sharp\">thread.
你应该尝试去学习书本节目,其中许多,你可以找到亚马逊或的 Wrox的像标签:asp.net,C#,编程

希望它能帮助

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";

    }
}
 }

解决方案

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

这篇关于在复制一个Web应用程序进入到一个单独的页面的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆