ImageButton

Discussion in 'ASP .Net' started by =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?=, Aug 12, 2007.

  1. 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
    =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?=, Aug 12, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo

    Prevent Postback with ImageButton

    Marcelo, Jul 1, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    917
    Kairi Zikpin
    Jul 1, 2003
  2. ganesh kolappan

    image/imagebutton client validation

    ganesh kolappan, Jul 3, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    480
    David Waz...
    Jul 3, 2003
  3. Matthew
    Replies:
    2
    Views:
    571
    Ken Cox [Microsoft MVP]
    Jul 9, 2003
  4. Edmilson

    Imagebutton over a little text

    Edmilson, Jul 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    379
    Steve C. Orr, MCSD
    Jul 30, 2003
  5. Jake
    Replies:
    2
    Views:
    404
Loading...

Share This Page