我给Button按钮加onclick事件,代码如下Button1.Attributes.Add("onclick", "Response.Write(\"<script>window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1','width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200');</script>);");
说“未结束的字符串常量”,请求帮助

解决方案 »

  1.   

    在页面上查看源文件看看。如果ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value 这些变量中有单引号或双引号就破坏了脚本的完整性,就出现这个错误了。
      

  2.   


    <input type="submit" name="GridView1$ctl02$Button1" value="Button" onclick="Response.Write(&quot;&lt;script>window.open('ProductsQuotationUpLoad.aspx?ProjectNo=B41193001&amp;BaoJiaDanID=B41193001-TSBJ20090908171709&amp;FileTypeID=44,45','new1','width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200');&lt;/script>);" id="GridView1_ctl02_Button1" />
    麻烦帮看下!谢谢!
      

  3.   


    Button1.Attributes.Add("onclick", "<script language=\"javascript\">window.open(\"ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45\",\"new1\",\"width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200\");</script>)不需要在里面在Response.Write()了
      

  4.   


    Button1.Attributes.Add("onclick", "window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1','width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200')");
      

  5.   

    Button2.Attributes.Add("onclick", "Response.Write(\"<script type=\"text/javascript\">window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1','width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200');</script>);");
      

  6.   

    Button2.Attributes.Add("onclick", "Response.Write(\"<script type=\"text/javascript\">window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1','width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200');</script>);");
      

  7.   

    Button2.Attributes.Add("onclick", "javascript:window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1','width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200');");
      

  8.   


    Button1.Attributes.Add("onclick", "<script>window.open('ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45','new1',
    'width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200');</script>");
      

  9.   

    onclick是客户端事件,Response.Write是服务器端方法,你叫它怎么执行?正确的应该是5楼的写法
      

  10.   

    Button1.Attributes.Add("onclick", "<script language=\"javascript\">window.open(\"ProductsQuotationUpLoad.aspx?ProjectNo=" + ProjectNo + "&BaoJiaDanID=" + HDFBaoJiaDanID.Value + "&FileTypeID=44,45\",\"new1\",\"width=750,height=400,toolbar=0,scrollbars=2,top=200,left=200\");</script>)
    不需要在里面在Response.Write()了