Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.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# 如何将ImageMap控件和热点添加到由数据库中的图像填充的网页_C#_Webforms - Fatal编程技术网

C# 如何将ImageMap控件和热点添加到由数据库中的图像填充的网页

C# 如何将ImageMap控件和热点添加到由数据库中的图像填充的网页,c#,webforms,C#,Webforms,Im使用BinaryWrite方法显示sql中的jpg或gif图像。图像已按预期加载。我想在该图像上添加热点。我无法将任何ImageUrl指向ImageMap,因此我认为主要问题在于此 我在代码隐藏中添加了ImageMap控件和加载页面上的相关热点。没有成功 我将控件放在Response.End()之前,因为此后不再执行代码 在图像上未观察到热点。有没有办法做到这一点,因为我不能嵌入图像作为打开的文件在服务器上 这是我代码的最后一部分: protected void Page_Load(obje

Im使用BinaryWrite方法显示sql中的jpggif图像。图像已按预期加载。我想在该图像上添加热点。我无法将任何ImageUrl指向ImageMap,因此我认为主要问题在于此

我在代码隐藏中添加了ImageMap控件和加载页面上的相关热点。没有成功

我将控件放在
Response.End()
之前,因为此后不再执行代码

在图像上未观察到热点。有没有办法做到这一点,因为我不能嵌入图像作为打开的文件在服务器上

这是我代码的最后一部分:

protected void Page_Load(object sender, EventArgs e)
{
    // After db connection and filling the data
    try
    {
        objAdapter.Fill(objTable);

        objRow = objTable.Rows[0];
        byte[] objData;
        objData = (byte[])objRow["Resim"];
        string name = (string)objRow["ResimAd"];
        char[] sep = { '.' };
        string[] nname;
        nname = name.Split(sep);
        int il = nname.Length;

        if (nname[il - 1] == "pdf" || nname[il - 1] == "PDF")
        {
            Response.ContentType = "application/pdf";      
        }
        else if (nname[il - 1] == "xls" || nname[il - 1] == "XLS" || nname[il - 1] == "xlsx" || nname[il - 1] == "XLSX" || nname[il - 1] == "XLSB"
            || nname[il - 1] == "xlsb" || nname[il - 1] == "XLSM" || nname[il - 1] == "xlsm" || nname[il - 1] == "CSV" || nname[il - 1] == "csv")
        {
            Response.ContentType = "application/vnd.ms-excel";      // excel dosya
        }
        else if (nname[il - 1] == "doc" || nname[il - 1] == "docx" || nname[il - 1] == "rtf")
        {
            Response.ContentType = "application/vnd.ms-word";      
        }
        else
        {
            Response.ContentType = "image";          
        }

        Response.AppendHeader("Content-Disposition", "inline; filename=\"" + name + "\"");  
        Response.BinaryWrite(objData);
        Response.Flush();

        // Here I add ImageMap :
        ImageMap ImageMap1 = new ImageMap
        {
            HotSpotMode = HotSpotMode.Navigate,
        };
        Page.Controls.Add(ImageMap1);
        RectangleHotSpot hs1 = new RectangleHotSpot
        {
            Left = 0,
            Right = 500,
            Top = 0,
            Bottom = 500,
            AlternateText = "XXXXXXX",
            NavigateUrl = "~/Default.aspx"
        };
        ImageMap1.HotSpots.Add(hs1);
        Response.End();
    }
    catch (Exception ex)
    {
         labelError.Text = ex.ToString();
    }
}

我把图像地图放在FormView中。将二进制imagedata绑定到它,并将ImageUrl指向DataItem。因此,定义了ImageMap,可以添加任意数量的热点。工作完美。

ImageMap是一个HTML概念。它应该在使用/显示图像的页面中创建,而不是在创建图像的“页面”上。因此,您的意思是应该在aspx端添加ImageMap控件。我已经做过了。没有区别。此外,我必须在代码端添加热点,并记录它们的坐标。感谢那些感兴趣的人。我自己解决了这个问题。你应该在下面的答案框中发布你的解决方案,这样可能会对其他人有利。