<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Buttons.aspx.cs"
Inherits="WebDemo01.Buttons" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Buttons
Example</title>
<style type="text/css">
table, tr, td {
border: 1px solid purple;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table style="width:
auto">
<tr>
<td class="auto-style1">
<asp:Button ID="btnClickMe" runat="server" Text="Click
Me" OnClick="btnClickMe_Click" Width="100px" />
</td>
<td class="auto-style1">
<asp:Label ID="lblMsg1" runat="server"
Text="Output msg by button control"></asp:Label>
Text="Output msg by button control"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="imgbtnClickMe" runat="server" Height="30px" ImageUrl="~/images/ClickMe.png" OnClick="imgbtnClickMe_Click" Width="100px" />
</td>
<td>
<asp:Label ID="lblMsg2" runat="server"
Text="Output msg by Image button control"></asp:Label>
Text="Output msg by Image button control"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:LinkButton ID="lnkbtnClickMe" runat="server" OnClick="lnkbtnClickMe_Click">Click Me</asp:LinkButton>
</td>
<td>
<asp:Label ID="lblMsg3" runat="server"
Text="Output msg by Link button control"></asp:Label>
Text="Output msg by Link button control"></asp:Label>
</td>
</tr>
</table>
<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/index.aspx">
Back to Home Hyperlink</asp:HyperLink>
</form>
</body>
</html>
C# Code
using System;
namespace WebDemo01
{
public partial class Buttons: System.Web.UI.Page
{
protected void
btnClickMe_Click(object sender, EventArgs e)
{
lblMsg1.Text = "Hello user you have clicked me";
}
protected void
imgbtnClickMe_Click(object sender, ImageClickEventArgs e)
{
lblMsg2.Text = "Hello user you have clicked me (I am Image Button)";
}
protected void
lnkbtnClickMe_Click(object sender, EventArgs e)
{
lblMsg3.Text = "Hello user you have clicked me (I am Link Button)";
}
}
}
Output
No comments:
Post a Comment