前台代码:
<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(); 错误提示:未将对象引用设置到对象的实例
解决方案 »
- dropdownlist联合ajax技术使用问题望高手给解
- 为什么我搜索中有时候会出现The IListSource does not contain any data sources.
- 百分疑难问题,关于页面变量,在线等!
- 100分 求如何在aspx页面间传递xml格式的数据
- 关于从服务器端下载图片到客户端的问题!!!!!
- .NET 分块加载游戏地图的实现原理
- 各位大哥,大侠快帮忙啊,耽误看球了~!!今天可是kick鬼子阿~!!
- 请求帮助!
- sql2000问题,asp.net连接
- mvc怎么不自动生成表
- 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
}