user1285383
user1285383

Reputation: 73

how to pass parameter to js function in asp.net

I wannna pass 5 parameters to my js function. But someting wrong while passing these parameters. How to fix that?

  <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>

Upvotes: 0

Views: 739

Answers (1)

Claudio Redi
Claudio Redi

Reputation: 68400

Try with this

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

Upvotes: 2

Related Questions