UncleCoder.com

UncleCoder.com

Free programming examples and instructions

Excecute Javascript event from Asp button

Demo and Code for how to excecute javascript from asp.net button

by Athil


Posted on 13 May 2017 Category: Asp.net Views: 539

Edited on 04 Jun 2017



DEMO

Hi, Here I am going to show how to use javascript in Asp.net buttons. By using OnClientClick attribute to asp.net button we can use javascript in asp.net buttons. 

 <asp:Button ID="Button1" runat="server" OnClientClick="alert('from javascript');" Text="Button" />

Full Code

On Client Side



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>Demo Javascript Event on ASP Button </h1>
        <asp:Button ID="Button1" runat="server" OnClientClick="alert('from javascript');" Text="Click Here" />
    </div>
    </form>
</body>
</html>


Leave a Comment:


Advertisement