asp.net
2012-06-12 97 views 1 likes 
1

我想將5個參數傳遞給我的js函數。但傳遞這些參數時有些錯誤。如何解決這個問題?如何將參數傳遞給asp.net中的js函數

<asp:Button ID="btnRezAktar" runat="server" Text="Aktar" OnClientClick='<%# Eval("o_no", "SubmitPage(\"{0}\", ") + Eval("k_ad", "\"{0}\") + Eval("gir_tar", "\"{0}\") + Eval("cik_tar", "\"{0}\") + Eval("gece_say", "\"{0}\")") %>' /> 

<script language="javascript"> 
     function SubmitPage(o_no, k_ad, gir_tar, cik_tar, gece_say) { 
      window.opener.document.getElementById('txtRoomNo').value = o_no.toString(); 
      window.opener.document.getElementById('txtNameSurname').value = k_ad.toString(); 
      window.opener.document.getElementById('txtStartDate').value = gir_tar.toShortDateString(); 
      window.opener.document.getElementById('txtFinishDate').value = cik_tar.toShortDateString(); 
      window.opener.document.getElementById('txtNightNum').value = gece_say.toString(); 
      this.close(); 
     } 
    </script> 
+1

嘗試什麼是生成的HTML是什麼樣子? – jrummell

回答

2

與此

OnClientClick= 
    '<%# string.Format("SubmitPage('{0}','{1}','{2}','{3}','{4}')", Eval("o_no"), Eval("k_ad"), Eval("gir_tar"), Eval("cik_tar"), Eval("gece_say")) %>' 
相關問題