Solved

imagebutton as an href

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now