Solved

imagebutton as an href

Posted on 2006-07-13
4
1,476 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASCX file or a newer alternative? 1 35
SQL Login 17 50
How to parse the string and split the sub directory names in asp.net 7 41
How come this regular expression allows "e"? 14 38
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

809 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