if(item.find(a)!=null)
{
throw new Exception(string.Format("指定的商品 {0} {1} 已经添加在列表中。", A, B));
}
这句代码提示出来的是个空白的消息框子
A和B分别都有值。
if判断没错,但只要一进去,无论输出什么都是直接在页面弹出一个白色消息框子,一个确定按钮,按确定却也关不掉这个消息框子。
其他地方的throw new Exception输出没错。

解决方案 »

  1.   

    还有 不要用 Exception 控制程序流程可以指定返回值
      

  2.   

    我直接throw new Exception(“1111”)都出错。
    如果我放在if外面就没错。。
    换过放在else中也是一样的结果
      

  3.   

    item.find(a)看看这句有没有问题
      

  4.   

    if(item.find(a)!=null) 
    { } 
    else
    {
    throw new Exception(string.Format("指定的商品 {0} {1} 已经添加在列表中。", A, B)); 
    }
    同样的错。
    if(item.find(a)!=null) 

    throw new Exception(string.Format("。。")); 

    同样的错。
      

  5.   

    没有··我 换了种方法
    让他返回真假,同样进去就出错。
    item.find(a))这个方法直接让他返回了true,false同样出错
      

  6.   

    你加个try catch断点跟一下
      

  7.   

    问题可以确定了。你就算把整个语句都删了还是会出错的。我觉得是你其他地方写错了。如果你确定其他没写错的话。建议你更新一下asp.net javascript的脚本库
      

  8.   

     if (Item.Find(A) != null)
            {
                try
                {
                    throw new Exception(string.Format("指定的商品 {0} {1} 已经添加在列表中。", A, B));
                }
                catch (Exception l)
                {
                    throw new Exception("{0}",l);
                }
                
            }
    同样错误,出现空白消息框,框子无法关闭。
      

  9.   

    晕,不是让你把 异常 try catch是把 if (Item.Find(A) != null) 
            { 同时 try catch
      

  10.   

    但我就是不同,throw new Exception只要在if之外,都能正常,
    在别的if里也正常,就这一个不正常。
      

  11.   

    try
            {
                if (Item.Find(A) != null)
                {                throw new Exception(string.Format("指定的商品 {0} {1} 已经添加在列表中。", A, B));            }
            }
            catch (Exception l)
            {
                throw new Exception("{0}", l);
            }
    一样。
      

  12.   

    我 换了种判断的方法试了下,结果一样。
    for(int i=0;i<item.count;i++)
    {
        if(item[i].A==A)
        {
            throw new Exception(string.Format("指定的商品 {0} {1} 已经添加在列表中。", A, B));     }
    }
    出最后个括号直接出错。
      

  13.   

    那条判断可能有错误,我换了个最简单的判断,结果进去了,没出错。
    给你们看看这item的循环
      

  14.   

    public Item Find(Guid A)
        {
            foreach (Item Item in this)
            {
                if (Item.A == A)
                {
                    return Item;
                }
            }
            return null;
        }结合那判断看下错在哪?
      

  15.   

     foreach (Item Item in this) 
    ??
      

  16.   

    public ssItem Find(Guid A) 
        { 
            foreach (ssItem Item in this) 
            { 
                if (Item.A == A) 
                { 
                    return Item; 
                } 
            } 
            return null; 
        } 
      

  17.   

    public ssItem Find(Guid A) 
        { 
            ssItem  s=null;
            try      {
            foreach (ssItem Item in this) 
            { 
                if (Item.A == A) 
                { 
                    s= Item; 
                    break;
                } 
            } 
            }
            catch(Exception e){
                    s=null;
             }
            finally{
                    return s; 
             }
        } 
      

  18.   

    不能把 ssItem  s=null; 
      

  19.   

    你找你最外层的try/catch,你的catch里99.9%是MessageBox.Show("");之类的代码。
      

  20.   

    System.Exception发生
      消息=“指定的商品testm诺基亚N90 - 红色已经添加在列表中。”
      来源=“App_Web_qzucuwsu”
      堆栈跟踪:
           在StockEdit.AddButton_Click(对象发送,EventArgs五)在c:\ Documents和Settings \ shanmingjun \我的文档\ Visual Studio 2008的\项目\斯通\源代码\股票\ StockEdit.aspx.cs:行90
      的InnerException:
      

  21.   

    他指定90行就是 throw new Exception(string.Format("指定的商品 {0} {1} 已经添加在列表中。", A, B)); 
      

  22.   

    你把  throw new Exception 去掉让真正的错误出来
      

  23.   

    去 掉这个一切正常throw new Exception