AlternativeText, CommandName, CommandArgument, CausesValidation, ImageAlign, ImageUrl özellikleri;
OnClick,OnCommand metotları; Click ve Command olayları mevcuttur.
ImageAlign ile eklenen resmin pozisyonu belirlenir. AbsBottom, Absmiddle, BaseLine, Bottom, Left, Middle, NotSet, Right, TextTop, Top gibi değerler alır. Tasarım esnasında mutlaka işimize yarayacaktır. Bunun haricinde bir Button kontrolundan farksızdır.
OnClick metodu ile;
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void ImageButton1_Click(Object sender, EventArgs e)
{
Response.Write("Merhaba Çamlıca");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <title></title></head>
<body>
<form id="form1" runat="server"> <div>
<asp:ImageButton ID="ImageButton1" OnClick="ImageButton1_Click" Text="Çalıştır" runat="server" ImageUrl="~/Tus.png" AlternateText="Çalıştır" />
</div> </form>
</body>
</html>
veya OnCommand metodu ile;
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void ImageButton_Command(Object sender, CommandEventArgs e)
{
if (e.CommandName == "imagebuton1")
{
if (e.CommandArgument == "1")
{
Response.Write("Merhaba Çamlıca");
}
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server"> <title></title></head>
<body>
<form id="form1" runat="server"> <div>
<asp:ImageButton ID="ImageButton1" OnCommand="ImageButton_Command" CommandName="imagebuton1" CommandArgument="1" Text="Çalıştır" runat="server" ImageUrl="~/Tus.png" AlternateText="Çalıştır" />
</div> </form>
</body>
</html>
CommandArgument veya CommandName bu tür basit uygulamalarda birini kullanmasak da olur. Button kontrolunden gördüğümüz gibi uygulamada bir fark yok.
Hiç yorum yok:
Yorum Gönder