這是我的度假村網頁的C#代碼。問題是我無法多次顯示圖像。它可能可能爲一個圖像。但之後,它不再工作。請幫幫我。如何在C#asp.net的另一個頁面中顯示多個圖像
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Resorts : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 1)
{
Session["room"] = "Deluxe Room";
Label1.Text = "Classy Room";
Label2.Text = "Good for you";
Label3.Text = "100";
Session["rom"] = Session["rom"]+"<br>"+ DropDownList1.Text;
Session["prc"] = Session["prc"]+"<br>"+ Label3.Text;
Session["img"] = Session["img"]+"<br>"+ Image1.Imageurl;
}
else if (DropDownList1.SelectedIndex == 2)
{
Session["room"] = "Deluxe Room";
Label1.Text = "Nga-nga kayo";
Label2.Text = "Good for me";
Label3.Text = "100,000";
Session["rom"] = Session["rom"]+"<br>"+ DropDownList1.Text;
Session["prc"] = Session["prc"]+"<br>"+ Label3.Text;
Session["img"] = Session["img"]+"<br>"+ Image1.Imageurl;
}
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Biodata.aspx");
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex == 1)
{
Button1.Enabled = true;
Image1.ImageUrl = "~/Styles/Rooms/deluxe1.jpg";
Label1.Text = "";
Label2.Text = "";
Label3.Text = "";
}
else if (DropDownList1.SelectedIndex == 2)
{
Button1.Enabled = true;
Image1.ImageUrl = "~/Styles/Rooms/room2.jpg";
Label1.Text = "";
Label2.Text = "";
Label3.Text = "";
}
else
{
Label1.Text = "";
Label2.Text = "";
Label3.Text = "";
Image1.ImageUrl = "~/Styles/hand.jpg";
Button1.Enabled = false;
}
}
}
我用於圖像(Session["img"] = Session["img"]+"<br>"+ Image1.Imageurl;)
這個代碼是我希望它顯示的頁面。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Biodata : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Text = Session["name"].ToString();
TextBox2.Text = Session["adr"].ToString();
TextBox3.Text = Session["con"].ToString();
TextBox4.Text = Session["email"].ToString();
Label1.Text = Session["rom"].ToString();
Label5.Text = Session["prc"].ToString();
Label4.Text = Session["room"].ToString();
}
}
@ user3107231-你做錯了哥們......這不是綁定 –
@Rony遺憾之有道。這是我第一次來這裏。 – user3107231
爲什麼你使用會話顯示圖像的URL。這段代碼需要審查。詢問你的同事或同行審查。 – Piyush