简体   繁体   中英

Calling OnClientClick from Code behind in Asp.net VB

I have code like this :

<asp:LinkButton runat="server" ID="HL_KonfirmasiPemesanan" class="button-primary button-shadow" causesvalidation="false" validationgroup="ValidasiData"  OnClientClick="return getConfirmation(this);"  ></asp:LinkButton>

Then I want call OnClientClick="return getConfirmation(this);" in code behind, I tried:

HL_KonfirmasiPemesanan.Attributes.Add("OnClientClick", "return getConfirmation(this);")

but it doesn't work, how can I do that?

You can do this:

dim script as String = "<script>var btn = document.querySelector('.button-primary'); getConfirmation(btn);</script>"
ClientScript.RegisterStartupScript(Me.GetType(), "click_Btn", script)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM