我的问题是这样的:
<asp:TemplateField  HeaderText="(桂林)总" ItemStyle-Width="70px" ItemStyle-HorizontalAlign="Left" >   
              <ItemStyle HorizontalAlign="Left" Width="70px" />
              <ItemTemplate>
          <asp:HyperLink ID="Link" runat="server" Target="_blank" 
          Text='<%#Eval("totalGL")%>'  onclick="open1()" NavigateUrl="javascript:void(0)"></asp:HyperLink>
       </ItemTemplate>在一个HyperLink超链接中,有一个onclick="open1()" 事件,然后HyperLink超链接的NavigateUrl就不跳转,而是通过onclick="open1()"中的下面这个函数实现跳转:
<script type="text/javascript">
        function open1() {
            Dialog.open({ URL: "test1.aspx?bid=<%#Eval("BookID")%>" ,ShowButtonRow: true, Width: 350, Height: 550 });
        }
</script>,请问,我如何才能在Dialog.open({ URL: "test1.aspx?bid=<%#Eval("BookID")%>" 传递参数呢?我现在的写法不正确吗?怎么不能取值呢?C#  超链接  传值hyperlinkJavaScript函数

解决方案 »

  1.   

     onclick='open1(<%#Eval("BookID")%>)'function open1(bookId){
         Dialog.open({ URL: "test1.aspx?bid=" + bookId,ShowButtonRow: true, Width: 350, Height: 550});
    }
      

  2.   

    <asp:TemplateField  HeaderText="(桂林)总" ItemStyle-Width="70px" ItemStyle-HorizontalAlign="Left" >   
                  <ItemStyle HorizontalAlign="Left" Width="70px" />
                  <ItemTemplate>
              <asp:HyperLink ID="Link" runat="server" Target="_blank" 
              Text='<%#Eval("totalGL")%>'  onclick="open1('<%#Eval("BookID")%>')" NavigateUrl="javascript:void(0)"></asp:HyperLink>
           </ItemTemplate><script type="text/javascript">
            function open1(id) {
                Dialog.open({ URL: "test1.aspx?bid="+id ,ShowButtonRow: true, Width: 350, Height: 550 });
            }
    </script>
      

  3.   

    将hyerlink 改为<a href="javascript:open1('<%#Eval("BookID") %>')" ><%#Eval("totalGL")%></a>
      

  4.   

    这种方法还是不行,open1()这个函数里面传递过去的BookID在js中的function open1() {
                Dialog.open({ URL: "test1.aspx?bid=<%#Eval("BookID")%>" ,ShowButtonRow: true, Width: 350, Height: 550 });里面不能接收。Dialog.open(URL:)中,哪个URL是已经封装好了的,好像它不能接收变量。如果我将URL: "test1.aspx?bid=<%#Eval("BookID")%>"改为URL: "test1.aspx?bid=11的话,是可以接收11这个值的。求大家帮帮忙,这个问题困扰我一周了!!!!大家帮帮吧,我在网上找了好久也没找到好的解决办法。
      

  5.   

    这种方法还是不行,open1()这个函数里面传递过去的BookID在js中的function open1() {
                Dialog.open({ URL: "test1.aspx?bid=<%#Eval("BookID")%>" ,ShowButtonRow: true, Width: 350, Height: 550 });里面不能接收。Dialog.open(URL:)中,哪个URL是已经封装好了的,好像它不能接收变量。如果我将URL: "test1.aspx?bid=<%#Eval("BookID")%>"改为URL: "test1.aspx?bid=11的话,是可以接收11这个值的。求大家帮帮忙,这个问题困扰我一周了!!!!大家帮帮吧,我在网上找了好久也没找到好的解决办法。你open1是这样写的吗?
    function open1(id) {
                Dialog.open({ URL: "test1.aspx?bid="+id ,ShowButtonRow: true, Width: 350, Height: 550 });
            }
      

  6.   

    这种方法还是不行,open1()这个函数里面传递过去的BookID在js中的function open1() {
                Dialog.open({ URL: "test1.aspx?bid=<%#Eval("BookID")%>" ,ShowButtonRow: true, Width: 350, Height: 550 });里面不能接收。Dialog.open(URL:)中,哪个URL是已经封装好了的,好像它不能接收变量。如果我将URL: "test1.aspx?bid=<%#Eval("BookID")%>"改为URL: "test1.aspx?bid=11的话,是可以接收11这个值的。求大家帮帮忙,这个问题困扰我一周了!!!!大家帮帮吧,我在网上找了好久也没找到好的解决办法。
    就算那样写也不行。你看看我下面的代码:
    <script type="text/javascript">
            function open1() {
                Dialog.open({ URL: "test4.aspx?id="+<%#Eval("totalGL") %>, ShowButtonRow: true, Width: 350, Height: 550 });
            }
    </script>相应的单击事件是:
    <ItemTemplate>
             <a href="javascript:open1('<%#Eval("totalGL") %>')" ><%#Eval("totalGL")%></a>
           </ItemTemplate>
    主要实现的功能如下图所示: