2012-06-04 88 views
0

我想在我的列表視圖中將參數傳遞給我的js函數。我用一個參數做了這個。這樣的:asp.net將參數傳遞給列表視圖中的js函數

<asp:Button ID="btnRezAktar" runat="server" Text="Aktar" OnClientClick='<%# "SubmitPage(" + Eval("o_no") +");"%>' /> 

<script language="javascript"> 
     function SubmitPage(o_no) { 
      window.opener.document.getElementById('txtRoomNo').value = o_no.toString(); 
      this.close(); 
     } 
    </script> 

,但我想傳遞兩個參數,這是行不通的:

<asp:Button ID="btnRezAktar" runat="server" Text="Aktar" OnClientClick='<%# "SubmitPage(" + Eval("o_no") + "," + Eval("k_ad") + ");"%>' /> 

<script language="javascript"> 
     function SubmitPage(o_no, k_ad) { 
      window.opener.document.getElementById('txtRoomNo').value = o_no.toString(); 
      window.opener.document.getElementById('txtNameSurname').value = k_ad.toString(); 
     this.close(); 
     } 
    </script> 

有什麼不好呢?

+0

嘗試在第二個參數周圍添加雙引號或單引號。 – Tariqulazam

回答

0
OnClientClick='<%# Eval("o_no", "SubmitPage(\"{0}\", ") + Eval("k_ad", "\"{0}\")") %>' 
+0

非常感謝你! – user1285383