Link to home
Start Free TrialLog in
Avatar of jumpstart0321
jumpstart0321

asked on

ASP.net 2.0 OnClientClick imageButton problem.

Here's the sample url:
http://webspider.com/Default.aspx?search=sample
I'm having a problem with getting the onClientClick to work. As you can see on the page, there is images and I have set all their URL's dynamically so that they link to the product descriptions. However, it doesn't seem to be working as you can see in the url. It just posts back to the same page. The page pops up with a script error at the exact location of the imageButton. Any ideas as to what's causing my problem?
Avatar of amanola
amanola
Flag of United States of America image

Does your OnClientClick reference a JavaScript? OnClientClick is used for client side scripting OnClick is used for server side scripting. What is your script handled OnClientClick?
The javascript in the onClientClick is incorrect

it should be like this:
onclick="document.location.href = 'http://www.webspider.com/69218 Sample by Meyda Tiffany_13494513.html';"
My other thought is that if all you want to do is link to another page you can use the PostBackUrl of the ImageButton to just enter a link. This can also be bound to if necessary.
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jumpstart0321
jumpstart0321

ASKER

Thanks for all the help guys. I didn't reference anyexternal javascript, however; I believe the control automatically makes its own javascript at runtime. I tried the PostBackURL and got the same result. I took prariedog's suggestion and just used a basic <a href... control. Much easier and I'm sure it will be more SEO compatible. Thanks again guys.