By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,301 Members | 3,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,301 IT Pros & Developers. It's quick & easy.

<a href> around an <asp:imagebutton> not working - need some help

P: n/a
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif" runat="server"></asp:imagebutton></A>

When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button to
look at other categories, all the links I have around these buttons direct to
their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help

Nov 19 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
I also tried removing the <a href> tags around the ImageButtons and creating
Click events for the buttons with
Response.Redirect("savings.aspx?category=whatever" );
and placed a breakpoint on these statements in my Click code and they don't
event get executed.

I must be missiong something really small here :P

Thanks again

"tperri" wrote:
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif" runat="server"></asp:imagebutton></A>

When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button to
look at other categories, all the links I have around these buttons direct to
their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help

Nov 19 '05 #2

P: n/a
That is probable because the ImageButton is rendered as an <input> element
in the HTML.

Why do you want to wrap an ImageButton in an anchor? Suppose what you
wanted to do works, when the postback happens, how is the hyperlink suppose
to react since the past has already navigated. After all, the browser
cannot navigate to two pages at the same time.
"tperri" <tp****@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
I also tried removing the <a href> tags around the ImageButtons and creating Click events for the buttons with
Response.Redirect("savings.aspx?category=whatever" );
and placed a breakpoint on these statements in my Click code and they don't event get executed.

I must be missiong something really small here :P

Thanks again

"tperri" wrote:
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif" runat="server"></asp:imagebutton></A>
When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button to look at other categories, all the links I have around these buttons direct to their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help

Nov 19 '05 #3

P: n/a
Yes. This is the right way to do what you want.

If your button do not receive event, make sure you see something like this
in "Generated by form designer" part of code:

imgFood.Click += new ImageClickEventHandler(imgFoodClick);

The form designer should have added this to your code, but sometime for
unknown reason they're removed, so you should check it first.

"tperri" <tp****@discussions.microsoft.com> 级糶秎ン穝籇:93********************************* *@microsoft.com...
I also tried removing the <a href> tags around the ImageButtons and
creating
Click events for the buttons with
Response.Redirect("savings.aspx?category=whatever" );
and placed a breakpoint on these statements in my Click code and they
don't
event get executed.

I must be missiong something really small here :P

Thanks again

"tperri" wrote:
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif"
runat="server"></asp:imagebutton></A>

When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button
to
look at other categories, all the links I have around these buttons
direct to
their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help

Nov 19 '05 #4

P: n/a
What server-side functionality do you expect from the imagebutton? Can you
do just

<A href="Savings.aspx?category=Food"><:img
src="images\buttons\btn-food-i.gif"></A>
Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif" runat="server"></asp:imagebutton></A>
When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button to
look at other categories, all the links I have around these buttons direct to their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help

Nov 19 '05 #5

P: n/a
I need to change the images depending on the category so that the "actrive"
category has a different image differentiating it from the others; that is
why I'm using a server side control

"Eliyahu Goldin" wrote:
What server-side functionality do you expect from the imagebutton? Can you
do just

<A href="Savings.aspx?category=Food"><:img
src="images\buttons\btn-food-i.gif"></A>
Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif"

runat="server"></asp:imagebutton></A>

When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button to
look at other categories, all the links I have around these buttons direct

to
their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help


Nov 19 '05 #6

P: n/a
<td><asp:imagebutton id="imgHair" ImageUrl="images\buttons\btn-hair-i.gif"
runat="server"></asp:imagebutton></td>I do have the Event handlers... here is
my current html:
and my event handler:
this.imgHair.Click += new
System.Web.UI.ImageClickEventHandler(this.imgHair_ Click);

and my function:
private void imgHair_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect("savings.aspx?category=Hair");
}

I'm baffled.
"Lau Lei Cheong" wrote:
Yes. This is the right way to do what you want.

If your button do not receive event, make sure you see something like this
in "Generated by form designer" part of code:

imgFood.Click += new ImageClickEventHandler(imgFoodClick);

The form designer should have added this to your code, but sometime for
unknown reason they're removed, so you should check it first.

"tperri" <tp****@discussions.microsoft.com> 录露录g漏贸露l楼贸路s禄D:93*********************** ***********@microsoft.com...
I also tried removing the <a href> tags around the ImageButtons and
creating
Click events for the buttons with
Response.Redirect("savings.aspx?category=whatever" );
and placed a breakpoint on these statements in my Click code and they
don't
event get executed.

I must be missiong something really small here :P

Thanks again

"tperri" wrote:
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif"
runat="server"></asp:imagebutton></A>

When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button
to
look at other categories, all the links I have around these buttons
direct to
their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help


Nov 19 '05 #7

P: n/a
That's fine. Just use asp:image instead of asp:imagebutton.

Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
I need to change the images depending on the category so that the "actrive" category has a different image differentiating it from the others; that is
why I'm using a server side control

"Eliyahu Goldin" wrote:
What server-side functionality do you expect from the imagebutton? Can you do just

<A href="Savings.aspx?category=Food"><:img
src="images\buttons\btn-food-i.gif"></A>
Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
I have an HTML table with several fields like this:

<A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
ImageUrl="images\buttons\btn-food-i.gif"

runat="server"></asp:imagebutton></A>

When the user sees these buttons, they will currently be on the
savings.aspx?category=whatever page, and when they click another button to look at other categories, all the links I have around these buttons
direct to
their various categories.

However, when I press these buttons, nothing happens.

Did I forget to do something here?

thanks for the help


Nov 19 '05 #8

P: n/a
Did not you first ask on an imagebutton inside a hyperlink? Why do you want
to redirect in the imagebutton event if the hyperlink does it for you? Make
your mind and navigate with only one control : either the button or the
link.

Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
<td><asp:imagebutton id="imgHair" ImageUrl="images\buttons\btn-hair-i.gif"
runat="server"></asp:imagebutton></td>I do have the Event handlers... here is my current html:
and my event handler:
this.imgHair.Click += new
System.Web.UI.ImageClickEventHandler(this.imgHair_ Click);

and my function:
private void imgHair_Click(object sender, System.Web.UI.ImageClickEventArgs e) {
Response.Redirect("savings.aspx?category=Hair");
}

I'm baffled.
"Lau Lei Cheong" wrote:
Yes. This is the right way to do what you want.

If your button do not receive event, make sure you see something like this
in "Generated by form designer" part of code:

imgFood.Click += new ImageClickEventHandler(imgFoodClick);

The form designer should have added this to your code, but sometime for
unknown reason they're removed, so you should check it first.

"tperri" <tp****@discussions.microsoft.com>

级糶秎ン穝籇:93********************************* *@microsoft.com...
I also tried removing the <a href> tags around the ImageButtons and
creating
Click events for the buttons with
Response.Redirect("savings.aspx?category=whatever" );
and placed a breakpoint on these statements in my Click code and they
don't
event get executed.

I must be missiong something really small here :P

Thanks again

"tperri" wrote:

> I have an HTML table with several fields like this:
>
> <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
> ImageUrl="images\buttons\btn-food-i.gif"
> runat="server"></asp:imagebutton></A>
>
> When the user sees these buttons, they will currently be on the
> savings.aspx?category=whatever page, and when they click another button> to
> look at other categories, all the links I have around these buttons
> direct to
> their various categories.
>
> However, when I press these buttons, nothing happens.
>
> Did I forget to do something here?
>
> thanks for the help
>
>
>


Nov 19 '05 #9

P: n/a
That is what i originally did, and I was getting the same result - nothing.
It looked like it was posting back but it didn't go through the Page_Load
again. I set a break point there and nothing.

"Eliyahu Goldin" wrote:
That's fine. Just use asp:image instead of asp:imagebutton.

Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
I need to change the images depending on the category so that the

"actrive"
category has a different image differentiating it from the others; that is
why I'm using a server side control

"Eliyahu Goldin" wrote:
What server-side functionality do you expect from the imagebutton? Can you do just

<A href="Savings.aspx?category=Food"><:img
src="images\buttons\btn-food-i.gif"></A>
Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:51**********************************@microsof t.com...
> I have an HTML table with several fields like this:
>
> <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
> ImageUrl="images\buttons\btn-food-i.gif"
runat="server"></asp:imagebutton></A>
>
> When the user sees these buttons, they will currently be on the
> savings.aspx?category=whatever page, and when they click another button to > look at other categories, all the links I have around these buttons direct to
> their various categories.
>
> However, when I press these buttons, nothing happens.
>
> Did I forget to do something here?
>
> thanks for the help
>
>
>


Nov 19 '05 #10

P: n/a
In your original post you had an imagebutton inside a hyperlink. I am
suggesting having an image, not imagebutton. What page do you expect
Page_Load to happen? If you user the hyperlink for navigating, there won't
be any postback to the original form. Browser will navigate straight to the
new url.

Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
That is what i originally did, and I was getting the same result - nothing. It looked like it was posting back but it didn't go through the Page_Load
again. I set a break point there and nothing.

"Eliyahu Goldin" wrote:
That's fine. Just use asp:image instead of asp:imagebutton.

Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
I need to change the images depending on the category so that the

"actrive"
category has a different image differentiating it from the others; that is why I'm using a server side control

"Eliyahu Goldin" wrote:

> What server-side functionality do you expect from the imagebutton?
Can you
> do just
>
> <A href="Savings.aspx?category=Food"><:img
> src="images\buttons\btn-food-i.gif"></A>
>
>
> Eliyahu
>
> "tperri" <tp****@discussions.microsoft.com> wrote in message
> news:51**********************************@microsof t.com...
> > I have an HTML table with several fields like this:
> >
> > <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
> > ImageUrl="images\buttons\btn-food-i.gif"
> runat="server"></asp:imagebutton></A>
> >
> > When the user sees these buttons, they will currently be on the
> > savings.aspx?category=whatever page, and when they click another

button to
> > look at other categories, all the links I have around these
buttons direct
> to
> > their various categories.
> >
> > However, when I press these buttons, nothing happens.
> >
> > Did I forget to do something here?
> >
> > thanks for the help
> >
> >
> >
>
>
>


Nov 19 '05 #11

P: n/a
Ok, forget all the code I posted to you.

I replaced everything with an Image Button .... in the Click event of that
button I have a Response.Redirect("savings.aspx?category=Whatever" ); and that
doesn't work....

have any idea about that?

"Eliyahu Goldin" wrote:
In your original post you had an imagebutton inside a hyperlink. I am
suggesting having an image, not imagebutton. What page do you expect
Page_Load to happen? If you user the hyperlink for navigating, there won't
be any postback to the original form. Browser will navigate straight to the
new url.

Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
That is what i originally did, and I was getting the same result -

nothing.
It looked like it was posting back but it didn't go through the Page_Load
again. I set a break point there and nothing.

"Eliyahu Goldin" wrote:
That's fine. Just use asp:image instead of asp:imagebutton.

Eliyahu

"tperri" <tp****@discussions.microsoft.com> wrote in message
news:3B**********************************@microsof t.com...
> I need to change the images depending on the category so that the
"actrive"
> category has a different image differentiating it from the others; that is > why I'm using a server side control
>
> "Eliyahu Goldin" wrote:
>
> > What server-side functionality do you expect from the imagebutton? Can you
> > do just
> >
> > <A href="Savings.aspx?category=Food"><:img
> > src="images\buttons\btn-food-i.gif"></A>
> >
> >
> > Eliyahu
> >
> > "tperri" <tp****@discussions.microsoft.com> wrote in message
> > news:51**********************************@microsof t.com...
> > > I have an HTML table with several fields like this:
> > >
> > > <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
> > > ImageUrl="images\buttons\btn-food-i.gif"
> > runat="server"></asp:imagebutton></A>
> > >
> > > When the user sees these buttons, they will currently be on the
> > > savings.aspx?category=whatever page, and when they click another
button to
> > > look at other categories, all the links I have around these buttons direct
> > to
> > > their various categories.
> > >
> > > However, when I press these buttons, nothing happens.
> > >
> > > Did I forget to do something here?
> > >
> > > thanks for the help
> > >
> > >
> > >
> >
> >
> >


Nov 19 '05 #12

P: n/a
Then, give your server-side form an id and try to type the following line in
the address bar of your browser after your page is opened.

javascript:window.alert(document.getElementById('i mgHair').form.id)

If the browser popups undefined/null/<blank> but not your form's id, you
should consider checking to see if all html tags(especially <form> and
<table>)are properly closed and not overlapped. In this case the imagebutton
is not attached to the postbackable form so not postback event can be fired.

"tperri" <tp****@discussions.microsoft.com> 级糶秎ン穝籇:93********************************* *@microsoft.com...
<td><asp:imagebutton id="imgHair" ImageUrl="images\buttons\btn-hair-i.gif"
runat="server"></asp:imagebutton></td>I do have the Event handlers... here
is
my current html:
and my event handler:
this.imgHair.Click += new
System.Web.UI.ImageClickEventHandler(this.imgHair_ Click);

and my function:
private void imgHair_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect("savings.aspx?category=Hair");
}

I'm baffled.
"Lau Lei Cheong" wrote:
Yes. This is the right way to do what you want.

If your button do not receive event, make sure you see something like
this
in "Generated by form designer" part of code:

imgFood.Click += new ImageClickEventHandler(imgFoodClick);

The form designer should have added this to your code, but sometime for
unknown reason they're removed, so you should check it first.

"tperri" <tp****@discussions.microsoft.com> ???gco?los?D:93******************************* ***@microsoft.com...
>I also tried removing the <a href> tags around the ImageButtons and
>creating
> Click events for the buttons with
> Response.Redirect("savings.aspx?category=whatever" );
> and placed a breakpoint on these statements in my Click code and they
> don't
> event get executed.
>
> I must be missiong something really small here :P
>
> Thanks again
>
> "tperri" wrote:
>
>> I have an HTML table with several fields like this:
>>
>> <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
>> ImageUrl="images\buttons\btn-food-i.gif"
>> runat="server"></asp:imagebutton></A>
>>
>> When the user sees these buttons, they will currently be on the
>> savings.aspx?category=whatever page, and when they click another
>> button
>> to
>> look at other categories, all the links I have around these buttons
>> direct to
>> their various categories.
>>
>> However, when I press these buttons, nothing happens.
>>
>> Did I forget to do something here?
>>
>> thanks for the help
>>
>>
>>


Nov 19 '05 #13

P: n/a
I guess it's not a good sign if I do this.. and nothing happens.. and in the
lower bar of IE I get the yellow exclamation point that says error on page :)

"Lau Lei Cheong" wrote:
Then, give your server-side form an id and try to type the following line in
the address bar of your browser after your page is opened.

javascript:window.alert(document.getElementById('i mgHair').form.id)

If the browser popups undefined/null/<blank> but not your form's id, you
should consider checking to see if all html tags(especially <form> and
<table>)are properly closed and not overlapped. In this case the imagebutton
is not attached to the postbackable form so not postback event can be fired.

"tperri" <tp****@discussions.microsoft.com> 录露录g漏贸露l楼贸路s禄D:93*********************** ***********@microsoft.com...
<td><asp:imagebutton id="imgHair" ImageUrl="images\buttons\btn-hair-i.gif"
runat="server"></asp:imagebutton></td>I do have the Event handlers... here
is
my current html:
and my event handler:
this.imgHair.Click += new
System.Web.UI.ImageClickEventHandler(this.imgHair_ Click);

and my function:
private void imgHair_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Response.Redirect("savings.aspx?category=Hair");
}

I'm baffled.
"Lau Lei Cheong" wrote:
Yes. This is the right way to do what you want.

If your button do not receive event, make sure you see something like
this
in "Generated by form designer" part of code:

imgFood.Click += new ImageClickEventHandler(imgFoodClick);

The form designer should have added this to your code, but sometime for
unknown reason they're removed, so you should check it first.

"tperri" <tp****@discussions.microsoft.com> ???gco?l垄Do隆Ps?D:93***************************** *****@microsoft.com...

>I also tried removing the <a href> tags around the ImageButtons and
>creating
> Click events for the buttons with
> Response.Redirect("savings.aspx?category=whatever" );
> and placed a breakpoint on these statements in my Click code and they
> don't
> event get executed.
>
> I must be missiong something really small here :P
>
> Thanks again
>
> "tperri" wrote:
>
>> I have an HTML table with several fields like this:
>>
>> <A href="Savings.aspx?category=Food"><asp:imagebutton id="imgFood"
>> ImageUrl="images\buttons\btn-food-i.gif"
>> runat="server"></asp:imagebutton></A>
>>
>> When the user sees these buttons, they will currently be on the
>> savings.aspx?category=whatever page, and when they click another
>> button
>> to
>> look at other categories, all the links I have around these buttons
>> direct to
>> their various categories.
>>
>> However, when I press these buttons, nothing happens.
>>
>> Did I forget to do something here?
>>
>> thanks for the help
>>
>>
>>


Nov 19 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.