【问题标题】:Send data from one webform to another?将数据从一个网络表单发送到另一个?
【发布时间】:2013-09-23 16:44:04
【问题描述】:

我想将视频名称从一个网络表单发送到另一个网络表单。这是使用各种技术实现的,例如查询字符串、会话、应用程序、cookie 是的!但我面临的问题是我有一个循环从哪里发送这些数据。

   protected void Page_Load(object sender, EventArgs e)
    {

        foreach (string strfile in Directory.GetFiles(Server.MapPath("~/Uploads1" + User.Identity.Name)))
        {
            ImageButton imageButton = new ImageButton();
            FileInfo fi = new FileInfo(strfile);
            imageButton.ImageUrl = "Uploads1" + User.Identity.Name +"/" + fi.Name;
            imageButton.Height = Unit.Pixel(100);
            imageButton.Style.Add("padding", "5px");
            imageButton.Width = Unit.Pixel(100);
            imageButton.Click += new ImageClickEventHandler(ImageButton1_Click);
            imageButton.AlternateText = fi.Name;
            imageButton.ToolTip = "View " + fi.Name;
            Panel1.Controls.Add(imageButton);

        }

    }
    //Show the actual sized image on clicking the image
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("Videos.aspx?VideoURL=" + ((ImageButton)sender).ImageUrl);
    }

现在我想将作为视频名称的“fi.Name”发送到其他网络表单,并将名称显示在具有以下代码的链接按钮上:

protected void Page_Load(object sender, EventArgs e)
    {
        VideoPlayer1.Mp4Url = Request.QueryString["VideoURL"];
       // LinkButton1.Text = 
    }

任何帮助将不胜感激。 附言如果我使用 cookie,发送的文本是所有文件的最后一个视频名称。

【问题讨论】:

    标签: c# asp.net cookies webforms


    【解决方案1】:

    您可以将名称作为您发送到 Videos.aspx 页面的查询字符串的一部分添加。

    var imgButton = (ImageButton)sender;
    
    Response.Redirect("Videos.aspx?VideoURL=" + imgButton.ImageUrl+"&Name="+imgButton.ToolTip;
    

    在页面加载时您可以分配它。

    LinkButton1.Text = Request.QueryString["Name"].ToString().Replace("View ", "");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-17
      • 2017-04-26
      • 2010-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多