Solved

imagebutton as an href

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video discusses moving either the default database or any database to a new volume.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

24 Experts available now in Live!

Get 1:1 Help Now