How to add an onClick event to a Label in asp.net

asp.net example - label onclick
test.aspx

<%@ Page Language="C#" AutoEventWireup="true"%>  
    
<!DOCTYPE html>
      
<script runat="server">
    void Page_Load(object sender, EventArgs e)
    {
        Label1.Attributes.Add("OnClick", "javascript:alert('label clicked.')");
    }    
</script>      
      
<html xmlns="http://www.w3.org/1999/xhtml">      
<head id="Head1" runat="server">      
    <title>asp.net example - label onclick</title>      
</head>      
<body>      
    <form id="form1" runat="server">      
    <div>      
        <h2 style="color:MidnightBlue; font-style:italic;">      
            asp.net example - label onclick
        </h2>      
        <hr width="550" align="left" color="Gainsboro" />      
        <asp:Label       
            ID="Label1"       
            runat="server"      
            Font-Size="XX-Large"
            Text="Click Here To Test Label OnClick Event."    
            >      
        </asp:Label>      
    </div>      
    </form>      
</body>      
</html>
More asp.net examples