1、如果用Reader来读数据库,是必须要判断的
  string str = reader["field"]==DBNull.Value?string.Empty:reader["field"].ToString()2、在Page_Load中给LinkButton增加属性:
  
  string script = "window.open(MoreInfo.aspx?Uid=" + str + ",\"\",\"top=0,left=0,width=350,height=250,resizable=no,status=no,scrollbars=no,toolbar=no,menubar=no,location=no\");");  lbtn.Attributes.Add("onclick","javascript:"+script);

解决方案 »

  1.   

    有没有VB的写法?
    Dim script As String = "window.open (MoreInfo.aspx?Uid=" + Str + ",\" \ ",\"top=0,left=0,width=350,height=250,resizable=no,status=no,scrollbars=no,toolbar=no,menubar=no,location=no\");"
                linkbutton3.Attributes.Add("onclick", "javascript:" + script)
    这样写了top=0,left=0,width=350,height=250,resizable=no,status=no,scrollbars=no,toolbar=no,menubar=no,location=no需要语句结束
    script未定义
    谢谢
      

  2.   

    我在我的linkbutton的onclick事件里添加了下面这段代码:
            url = "MoreInfo.aspx?Uid=" + str
            Dim status As String = "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no"
            Response.Write("<script language=JavaScript>window.open(" + url + ",null," + status + ");</script>")
    可是点击了以后报错了,说是缺少:";"
    到底怎么添加这个代码啊?是不是在aspx的事件里不能添加jscript客户端代码啊?
      

  3.   

    楼上判断reader时也会有错,加上
    IF MYREADER.READ() THEN
        if isdbnull(myreader(0)) then
           '为空
        else
           '不空
        end if
    end if
    onclickdim JsStr
    JsStr="<script language=JavaScript>" & chr(13)
    JsStr=jsstr & "window.open('*.aspx,'NewWindow');" & chr(13)
    JsStr=jsstr & "<"
    JsStr=jsstr & "/"
    JsStr=jsstr & "script>"
    if( not IsClientScriptBlockRegistered("ClientScript")) then
    RegisterClientScriptBlock("ClientScript",JsStr)
    end if
      

  4.   

    Dim status As String = "height=200,width=400,status=yes,toolbar=no,menubar=no,location=no"
    改成:
    Dim status As String = "'height=200,width=400,status=yes,toolbar=no,menubar=no,location=no'"
      

  5.   

    万分感谢,广告框的问题终于解决了
    to xd123(朝天一棍):
    myreader(0)是什么意思?
    因为我现在有许多列可以为空,我又不想对每一列都要判断是否为空,请问有什么方法可以不用一列一列的判断?不知道说清楚没有。我举个例子:
    Uclass.Text = op.MyReader("职称")
    Uodept.Text = op.MyReader("原专业")
    职称和原专业都可以为空,但是我不想对这两个都用if...then判断,可不可以对读出来的myreader的值先进行判断是否为空值,然后加以处理,然后再赋值给控件的text属性?谢谢!一经解决马上给分!
      

  6.   

    向timmy3310(tim)严谨的态度致敬!现在解决了,很感谢,分不多,大家还这么热心,谢谢