前台代码: 
<asp:Image ID="imgShow" runat="server"  AlternateText="无图片显示" BorderWidth="0px" />
            
后台代码:
            string imagestr="http://localhost:16991/BSMS/ChaffMessage/GetTemporImg.aspx?ImID=424";
            if (imagestr != string.Empty)
            {
                    string imageid = imagestr.Remove(0, imagestr.LastIndexOf("=") + 1);
                    this.imgShow.ImageUrl = "GetTemporImg2.aspx?ImID=" +imageid.ToString();
             }   
出现错误的语句就是:this.imgShow.ImageUrl = "GetTemporImg2.aspx?ImID=" +imageid.ToString(); 错误提示:未将对象引用设置到对象的实例

解决方案 »

  1.   

    详细代码,见:http://topic.csdn.net/u/20091114/14/4dde7c73-d2af-44ef-9967-f82ada3e7289.html
      

  2.   

    调试:imgShow是否为空
    if(imgShow!=null)
    {
    this.imgShow.ImageUrl = "GetTemporImg2.aspx?ImID=" +imageid.ToString(); }
      

  3.   

    imagestr != string.Empty
    这里有问题。
    加一个imagestr != null 的判断
    还有string imageid 这里已经声明是string类型了。下面再来个tostring
      

  4.   


    imgShow的确为空,为啥呢??
      

  5.   

    if(!string.IsNullOrEmpty())
    {
    //检查GetTemporImg2.aspx页面赋值是否正确
    }
      

  6.   

    自己调试一下判断引用变量是不是为null,
    if(变量!=null)
    {
        //dosomethings
    }