HTMLButtonOnServerClick.aspx
<%@ Page Language="C#" %>
<script runat="server">
protected void Button1_ServerClick(object sender, System.EventArgs e)
{
int ImageSize =(Int16) Image1.Height.Value;
Image1.Height = ImageSize + 100;
Label1.Text = "Image Height: " + Image1.Height.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>How to use onserverclick event in HTML button control in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy; font-style:italic;">HTML Server Control Example: Using onserverclick event</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Bold="true"
ForeColor="IndianRed"
Font-Size="Larger"
>
</asp:Label>
<br /><br />
<asp:Image
ID="Image1"
runat="server"
ImageUrl="~/Images/Image1.jpg"
Height="250"
/>
<br />
<input
type="button"
id="Button1"
value="Increase Image Size"
runat="server"
onserverclick="Button1_ServerClick"
/>
</div>
</form>
</body>
</html>
No comments:
Post a Comment