简体   繁体   中英

how to call java-script on client click using asp.net

i am trying to ask the user "are you sure you want to submit" on button click if they select yes then i want to call another java-script function, how can i do that?

  <asp:LinkButton ID="btnSubmit" runat="server" CssClass="btn btn-primary btn-block" OnClientClick="return confirm('are you sure you want to submit?');" OnClick="btn_submit_Click"> 
    <i aria-hidden="true" class="glyphicon glyphicon-ok"></i>Submit
      </asp:LinkButton>

i also want to call this method: return validate() once the OnClient event is fired:

OnClientClick="return validate()"

Why dont you write a single function that confirms from the user and then fires the validate function?

function Confirm(){

if (confirm("are you sure you want to submit?") == true) {
    Validate();
} else {
    //
}
}

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