在后台new了一个img,然后给它赋地址,但是取出它的宽和高怎么无法使用啊。
Image img = new Image();
                img.ImageUrl = "touxiang.aspx?table=sell_list&id=" + id;
                if ( Convert.ToInt32(img.Width) > 0 && Convert.ToInt32(img.Height) > 0)
  红色部分判断该怎么写呢,总说无法将类型为“System.Web.UI.WebControls.Unit”的对象强制转换为类型“System.IConvertible”。
不太理解其中的内涵

解决方案 »

  1.   

    直接写img.Width>0&& img.Height>0 也不对
      

  2.   

    Image img = new Image(); 可以这样的?  Image是抽象类啊!
      

  3.   

                ImageList I = new ImageList();
                I.Images .Add();
                int WIDTH = I.Images[0].Width;
    IMAGE可以实例化???
    这样
      

  4.   


    System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath("touxiang.aspx?table=sell_list&id=" + id));
    if (Convert.ToInt32(img.Width) > 0 && Convert.ToInt32(img.Height) > 0)
    {
    }
      

  5.   

     System.Drawing.Image image; 
      this.image = System.Drawing.Image.FromFile(imagePath); 
     
      

  6.   


    touxiang.aspx?table=sell_list&id="+id 是个页面从数据库中读出二进制数据流生成图片的,这样写,显示虚拟路径不正确啊。
      

  7.   

    哪位给出出主意啊,那个imagelist我更不知道怎么用了,MSDN上那么复杂,能给我哥实例吗,比如我这个该咋弄啊。
      

  8.   

    img.Width属于System.Web.UI.WebControls.Unit
    用img.Width > System.Web.UI.WebControls.Unit.Pixel(0)试试
      

  9.   

                ImageList im = new ImageList();
                im.Images.Add(Bitmap.FromFile(@"D:\My Documents\我的视频\richie\Angel\1a3fdbfd05a12f1c08244dd2.jpg"));
                int width = im.Images[0].Width;
                int height = im.Images[0].Height;
                MessageBox.Show(width.ToString()+" "+height .ToString ());
      

  10.   

    5楼和12楼的,我这样用了,可是出现错误。“touxiang.aspx?table=sell_list&id=45”不是有效的虚拟路径。  再说下,我的这个touxiang.aspx?table=sell_list&id=45是读数据库中二进制数据并返回的
      

  11.   

    FromFile是不会为你解析aspx,生成Html流的.
    重新根据参数到数据库中去读图片,