views:

518

answers:

1

I have the following button

   <asp:ImageButton ID="button1" runat="server" 
   ImageUrl="~/image.jpg"
   CommandName = "id"
   CommandArgument = "1"
   onclick="button1_Click"
   />

and in code behind

protected void button1_Click(object sender, ImageClickEventArgs e)
{
    Response.Write(e.commandName);
}

this does not work!!, So my question is how to get value frombutton control?

+5  A: 

Hi ahmed

For this to work you need to subscribe to the Command event instead of the Click event. This is used when following the command pattern in ASP.NET

Ray Booysen