0

I want to send the name of the video from one webform to another. This is achieved using various techniques like query string, session, application, cookies yes! But the problem that I'm facing is I have a loop from where I got to send this data.

   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);
    }

Now I want to send the "fi.Name" which is the name of the Video to other web form, and display the name on a linkbutton which has the below code:

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

Any help would be appreciated. P.S. If I use cookies, the text which is being sent is the last video name to all the files.

4

1 回答 1

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 ", "");
于 2013-09-23T08:44:04.657 回答