zoukankan      html  css  js  c++  java
  • ASP.NET小技巧:使用Escape解決但双引号引发的问题。

    一:先看个下面2个列子来引出问题

    1.<input type="button"   onclick="javascript:popupWindowRefresh(510,'MessageBox.aspx?oid=<%#Eval("Id")%>&comment=<%#Eval("OrderComment")%>')"  value="留言" class="offWhiteBtn" />

    2.<input type="button"  ID="MessageButton" runat="server" onclick="javascript:popupWindowRefresh(510,'MessageBox.aspx?oid=<%#Eval("Id")%>&comment=<%#Eval("OrderComment")%>')"
                                        value="留言" class="offWhiteBtn" />

    第一个例子和第二个列子几乎相同唯一不同的是第二个是加了runat="server" 成为服务器标记。第一个例子可以编译通过,第二个无法编译同过,报什么“The server tag is not well formed.”的错误。

    二:解决方案

    不管是不是runat=server都是最外加单引号,里面用用双引号,如果里面还是要用字符串引号的话就用"\""可以解决。这个方案上面2种情况都可以用。

    <input type="button"  ID="MessageButton" runat="server" onclick='<%#"javascript:popupWindowRefresh(500,"+"\""+string.Format("MessageBox.aspx?oid={0}&comment={1}",Eval("Id").ToString(),Eval("OrderComment").ToString())+"\""+")"%>'
    value="留言" class="coffeeText" />

  • 相关阅读:
    模拟hadoop-rpc通信
    IOUtils方式上传下载文件
    HDFS基本操作的API
    HDFS基本命令行操作及上传文件的简单API
    gcj_2016_Round1_B
    hiho_1070_RMQ
    hiho_1068_RMQ_st算法
    hiho_1067_最近公共祖先2
    hiho_1062_最近公共祖先
    hiho_1066_并查集
  • 原文地址:https://www.cnblogs.com/scottpei/p/2382307.html
Copyright © 2011-2022 走看看