前台代码:
<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(); 错误提示:未将对象引用设置到对象的实例
<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(); 错误提示:未将对象引用设置到对象的实例
解决方案 »
- 后台如何给treeview的checkbox加tag属性
- 购物网站中,每卖一件衣服数量减1,同时在其他页面立即看到该数值
- asp.net如何解析无限极分类????
- 前台数据怎么传到后台,散分题
- gridview里imagefield字段的问题.
- vs2005里jmail发送出错大家来看看
- 在datagrid中绑定的dropdownlist显示的内容默认是数据库中的内容
- 问一个网页抓取的问题
- 简单功能,求源码,高手都来看一看哪。
- 问一个简单的javascript问题
- Repeater绑定数据后,怎么输出原来的字符串呢?<%#Eval("ProductID")%>这句原样输出...
- 未将对象引用设置到对象的实例
if(imgShow!=null)
{
this.imgShow.ImageUrl = "GetTemporImg2.aspx?ImID=" +imageid.ToString(); }
这里有问题。
加一个imagestr != null 的判断
还有string imageid 这里已经声明是string类型了。下面再来个tostring
imgShow的确为空,为啥呢??
{
//检查GetTemporImg2.aspx页面赋值是否正确
}
if(变量!=null)
{
//dosomethings
}