473,473 Members | 1,881 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

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
13 7402
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
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
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 #4
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
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
<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
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
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>

¼¶¼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 #9
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
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
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
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 #13
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Michael Evanchik | last post by:
The following tag works fine in internet explorer, but in mozilla the image is not sized and left at its actualy size. Anyone know why? I though asp.net works on any browswer. ...
1
by: Martin Schmid | last post by:
I'm getting a parser error message: Server tags cannot contain <% ... %> constructs... Ok.. so How do I accomplish this: For Each file in Files if ucase(right(file.name,7))<>ucase("_tn.jpg")...
11
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and...
17
by: Alan Silver | last post by:
Hello, I have a page which I am converting to use themes. The page has an HTML <input type="image"> element that is used to post to another page. I would like to replace this with a server...
4
by: R.A.M. | last post by:
Hello, Could anyone help me to handle <asp:Image> click in behind code? I have: <asp:Image ID="DotNETImage" ImageUrl="Images/DotNET_360x280.jpeg" AlternateText="Microsoft .NET version 2.0"...
0
by: Tom Edelbrok | last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a weird situation. If I start out with any ASPX page that contains an ImageButton control followed by a TextBox control,...
4
by: Jason | last post by:
Is that possible? How? <td > <asp:Label ID="StartDateLabel" runat="server" Text="Start Date:"> <asp:imagebutton ID="Imagebutton1" width=18 Height=18 CommandName=SetDate imageUrl="../cal.jpg"...
0
by: suganya | last post by:
Hi I have written the code for Atlas ModalPopup Control . The code is as follows <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register...
1
by: Jeff | last post by:
hi asp.net 3.5 (project upgraded from asp.net 2.0). are using vwd2008 express now This is my first ajax attempt. The code below shows a TextBox and a ListBox. The idea I was trying to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.