Solved

imagebutton as an href

Posted on 2006-07-13
4
1,478 Views
Last Modified: 2012-05-05
HI everyone,

I have a navigation menu where I've converted my 'a href' tags with rollover images inside them to asp:imagebuttons so they load more efficiently.

However, I'm a little unsure about the best way to add the redirection on each control, they are links to other pages in the site without coding behind.  All the controls are in an include file that is loaded with every page on the site so I don't really want to add response.redirect to every control on every page.

So, two questions:

1. Is there a way to redirect to a new page using an imagebutton in the actual aspx page?

2. I don't think I'd want the control to post back to the server would I?

<asp:ImageButton ImageUrl="Images/home.gif" onMouseOver="this.src='Images/home_rvs.gif';" onMouseOut="this.src='Images/home.gif';" runat="server" AlternateText="home" AutoPostBack="false" >

I hope all that makes sense!
thanks in advance
0
Comment
Question by:newbie_girl
  • 3
4 Comments
 
LVL 10

Expert Comment

by:orbulat
ID: 17105404
how about when you create the controls, add this attribute as well --> "onClick = xxxxxx" ?

<asp:ImageButton ImageUrl="Images/home.gif" onMouseOver="this.src='Images/home_rvs.gif';" onMouseOut="this.src='Images/home.gif';" runat="server" AlternateText="home" onClick="location.href='home.aspx'; return false;" >
0
 
LVL 10

Accepted Solution

by:
orbulat earned 250 total points
ID: 17105417
but if you type "onClick"'s actions within the imagebutton tag manually, it will cause error, sth. like it will conflicts with imagebutton click server events
it's ok if u add the onclick events in this way imagebutton1.Attributes.Add("onClick","location.href='home.aspx';return false;");

so if you really don't need server side codes for those image buttons, i will suggest you to use <a href='home.aspx' onClick="xxxxx"><img src='home.gif'></a> or <input type=image src='home.gif' onClick="xxxxx" />
0
 

Author Comment

by:newbie_girl
ID: 17105644
cool, so I'll have to add some server side code unless I use an A tag with an IMG.  

thanks orbulat :)
0
 
LVL 10

Expert Comment

by:orbulat
ID: 17106030
welcome :-)
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question