On Jun 13, 1:30 am, suzanne.bo...@gmail.com wrote:
> Hi,
> I'm adding an ImageButton as a child to a custom web control and
[quoted text clipped - 14 lines]
>
> Can anyone shed some light on why Button works but ImageButton doesn't.
This works for me
protected void Page_Load(object sender, EventArgs e)
{
ImageButton btn = new ImageButton();
btn.ID = "test";
btn.AlternateText = "test";
btn.CommandName = "test";
btn.CommandArgument = "1";
btn.Command += new CommandEventHandler(btn_Command);
form1.Controls.Add(btn);
}
void btn_Command(object sender, CommandEventArgs e)
{
Response.Write(e.CommandName + e.CommandArgument);
}
suzanne.boyle@gmail.com - 13 Jun 2007 18:33 GMT
I've found what is causing the problem. I have some javascript on the
page that hides ImageButtons container html element when it is
clicked. If I remove the javascript that does this it works.
Alexey Smirnov - 13 Jun 2007 21:18 GMT
On Jun 13, 7:33 pm, suzanne.bo...@gmail.com wrote:
> I've found what is causing the problem. I have some javascript on the
> page that hides ImageButtons container html element when it is
> clicked. If I remove the javascript that does this it works.
Great! Glad you got it working
suzanne.boyle@gmail.com - 13 Jun 2007 22:19 GMT
> On Jun 13, 7:33 pm, suzanne.bo...@gmail.com wrote:
>
[quoted text clipped - 3 lines]
>
> Great! Glad you got it working
I never actually got the ImageButton working. It seems when I capture
the document click event or the click event of the ImageButton's
container in javascript it stops the image button postback working
correctly. Instead I fudged a solution using a link button with an
image control inside.