ある Web フォームから別の Web フォームにビデオの名前を送信したい。これは、クエリ文字列、セッション、アプリケーション、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」を他のWebフォームに送信し、以下のコードを持つリンクボタンに名前を表示したいと思います:
protected void Page_Load(object sender, EventArgs e)
{
VideoPlayer1.Mp4Url = Request.QueryString["VideoURL"];
// LinkButton1.Text =
}
どんな助けでも大歓迎です。PS Cookie を使用する場合、送信されるテキストはすべてのファイルの最後のビデオ名です。