Solved

imagebutton as an href

Posted on 2006-07-13
4
1,479 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Data organization issue 7 36
Record locking on classic ASP 3 37
orderby list (from Json) 1 28
Web page design problem 3 12
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…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 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