0

データベースからリストビューにすべての画像を表示する必要がある小さなプロジェクトを行っています。画像 ID、幅、高さをクエリ文字列パラメーターとして渡します。

<asp:Image ID="Image1" runat="server" ImageUrl='<%#"~/Handler/ImageHandler.ashx?ImgHeight=150&ImgWidth=200&ImgID="+Eval("Image_ID")%>' Height="150px" Width="200px"/>
public void ProcessRequest (HttpContext context) 
    {

    string imgwidth = context.Request.QueryString["ImgWidth"];
    string imgheight = context.Request.QueryString["ImgHeight"];
    string imageid = context.Request.QueryString["ImgID"];
    if (imgwidth != string.Empty && imgheight != string.Empty && (imgwidth != null && imgheight != null))
    {
        if (!System.Web.UI.WebControls.Unit.Parse(imgwidth).IsEmpty && !System.Web.UI.WebControls.Unit.Parse(imgheight).IsEmpty)
        {
            //create unit object for height and width. This is to convert parameter passed in differen unit like pixel, inch into generic unit.
            System.Web.UI.WebControls.Unit widthUnit=System.Web.UI.WebControls.Unit.Parse(imgwidth);
            System.Web.UI.WebControls.Unit heightUnit = System.Web.UI.WebControls.Unit.Parse(imgheight);
            //AFTER THIS ???
        }

    }
}

データベースから直接画像を表示すると、一部の画像が伸びて見栄えが悪くなります。これは、画像サイズが大きいためです。そのため、画像ギャラリーにサムネイル用の画像を表示する必要があります。

4

2 に答える 2