G
Guest
Hello,
I tryed to use ImageButton in application I am currently working on. My
first idea was to use ImageButton just with AlternateText and add images
after application logic is fully working. Now I am wondering how odd the
behavior of ImageButton is because it does not generate Click event when
ImageUrl is not set up. I tryed it again outside of my application. I created
new web site with just one page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="btnAdd" AlternateText="Add" runat="server"
OnClick="btnAdd_Click" />
</div>
</form>
</body>
</html>
And code behind file:
using System;
using System.Web.UI;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void btnAdd_Click(object sender, ImageClickEventArgs e)
{ }
}
Then I tryed to investigate behavior of ImageButton. If ImageUrl is set up
it fires Page_Load and then btnAdd_Click as expected. But when ImageUrl is
missing or even worse when it is set up but image does not exist or cannot be
shown it fires only Page_Load and then second request arrives (GET HTTP
method) which is not a post back. The behavior was same on VS 2005 integrated
web server as well as on IIS 5.
I assume ImageButton should rise click everytime otherwise it is useless. Am
I right?
Thanks for any feedback,
Ladislav
I tryed to use ImageButton in application I am currently working on. My
first idea was to use ImageButton just with AlternateText and add images
after application logic is fully working. Now I am wondering how odd the
behavior of ImageButton is because it does not generate Click event when
ImageUrl is not set up. I tryed it again outside of my application. I created
new web site with just one page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="btnAdd" AlternateText="Add" runat="server"
OnClick="btnAdd_Click" />
</div>
</form>
</body>
</html>
And code behind file:
using System;
using System.Web.UI;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void btnAdd_Click(object sender, ImageClickEventArgs e)
{ }
}
Then I tryed to investigate behavior of ImageButton. If ImageUrl is set up
it fires Page_Load and then btnAdd_Click as expected. But when ImageUrl is
missing or even worse when it is set up but image does not exist or cannot be
shown it fires only Page_Load and then second request arrives (GET HTTP
method) which is not a post back. The behavior was same on VS 2005 integrated
web server as well as on IIS 5.
I assume ImageButton should rise click everytime otherwise it is useless. Am
I right?
Thanks for any feedback,
Ladislav