Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C#asp.net中在另一个页面中显示多个图像_C#_Asp.net - Fatal编程技术网

如何在C#asp.net中在另一个页面中显示多个图像

如何在C#asp.net中在另一个页面中显示多个图像,c#,asp.net,C#,Asp.net,这是我度假胜地网页的C#代码。问题是我不能多次显示图像。可能只有一张图片。但在那之后,它就不再起作用了。请帮帮我 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{

这是我度假胜地网页的C#代码。问题是我不能多次显示图像。可能只有一张图片。但在那之后,它就不再起作用了。请帮帮我

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

请在其他页面上尝试此代码

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

        string strImageUrls = Convert.ToString(Session["img"]);
        string[] arrImageUrls = strImageUrls.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
        if (arrImageUrls != null && arrImageUrls.Length > 0)
        {
            foreach (string strImageURL in arrImageUrls)
            {
                //DO your image binding here like
                //Image1.ImageUrl = strImageURL ;
            }
        }
    }
对按钮单击事件进行如下更改:

 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"] = Convert.ToString(Session["img"]) +  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"] = Convert.ToString(Session["img"]) + Image1.Imageurl + ",";

        }
    }
受保护的无效按钮1\u单击(对象发送者,事件参数e)
{
如果(DropDownList1.SelectedIndex==1)
{
会话[“房间”]=“豪华房”;
标签1.Text=“优雅房间”;
Label2.Text=“对你有好处”;
标签3.Text=“100”;
会话[“rom”]=会话[“rom”]+“
”+下拉列表1.Text; 会话[“prc”]=会话[“prc”]+“
”+标签3.文本; 会话[“img”]=Convert.ToString(会话[“img”])+Image1.Imageurl+“,”; } else if(DropDownList1.SelectedIndex==2) { 会话[“房间”]=“豪华房”; 标签1.Text=“Nga Nga kayo”; Label2.Text=“对我有好处”; 标签3.Text=“100000”; 会话[“rom”]=会话[“rom”]+“
”+下拉列表1.Text; 会话[“prc”]=会话[“prc”]+“
”+标签3.文本; 会话[“img”]=Convert.ToString(会话[“img”])+Image1.Imageurl+“,”; } }
@user3107231-你做错了,伙计。。。这不是一个正确的方法bind@Rony很抱歉这是我第一次来这里。为什么要使用会话显示图像url。这段代码需要审查。请您的同事或同行进行回顾。@Vikrants我试过了,先生。这是可能的。但问题是我不能重复第二次或更多。你没有合适的数据库吗?好的。先生我试试看。谢谢,先生。什么是图像绑定?只需将其误认为
Image1.ImageUrl=strImageURL
 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"] = Convert.ToString(Session["img"]) +  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"] = Convert.ToString(Session["img"]) + Image1.Imageurl + ",";

        }
    }