Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 12th, 2011, 05:38 PM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default Can asp:image work as href or...

Hi,

Can a <asp:image be used as an href or to open Url's?

<p><asp:Image id="Image1" ImageUrl="~/Img/Img1.jpg" runat="server"/></p>
Reply With Quote
  #2 (permalink)  
Old February 12th, 2011, 05:54 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Jim,

No, the Image control doesn't support that. However, you can turn things around and assign an image to a HyperLink or ImageButton:

Code:
 
<asp:HyperLink ID="HyperLink1" runat="server" ImageUrl="~/Img/Img1.jpg" />
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Img/Img1.jpg" />
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
JimP (February 12th, 2011)
  #3 (permalink)  
Old February 12th, 2011, 06:41 PM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Hi Imar,

Thank you, that looks great. But, it did not work in my code...
I get a: System.FormatException: Input string was invalid format
when I hit Button1

Can you take a look?


<script runat="server">
Sub submit(Sender As Object, e As EventArgs)
if red.Checked then
Hyperlink1.ImageUrl = "~/Img/Img1.jpg" And
Hyperlink1.NavigateUrl = "http://www.vg.no"
elseIf green.Checked then
Hyperlink1.ImageUrl = "~/Img/Img2.jpg" And
Hyperlink1.NavigateUrl = "http://www.dn.no"
elseIf blue.Checked then
Hyperlink1.ImageUrl = "~/Img/Img3.jpg"
end if
End Sub
</script>

<html>
<body>

<form id="Form1" runat="server">
Select:
<br />
<asp:RadioButton id="red" Text="Red" Checked="True"
GroupName="colors" runat="server"/>
<br />
<asp:RadioButton id="green" Text="Green"
GroupName="colors" runat="server"/>
<br />
<asp:RadioButton id="blue" Text="Blue"
GroupName="colors" runat="server"/>
<br />
<asp:Button ID="Button1" text="Submit" OnClick="submit" runat="server"/>
<p><asp:HyperLink id="Hyperlink1" runat="server" ImageUrl="~/Img/Img1.jpg" NavigateUrl= /></p>
&nbsp;<p><asp:Label id="Label1" runat="server"/></p>
</form>


Thanks!
JimP


Salute
www.Wimp.no
www.Spotify.com
Asia
Reply With Quote
  #4 (permalink)  
Old February 12th, 2011, 06:49 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Him Jim,

The And keywords shouldn't be there. Each assignment should simply be placed on its own line.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
JimP (February 12th, 2011)
  #5 (permalink)  
Old February 12th, 2011, 07:17 PM
Authorized User
Points: 89, Level: 1
Points: 89, Level: 1 Points: 89, Level: 1 Points: 89, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2011
Posts: 21
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Hi Imar!

It worked!!! Thank you!!!

I smile from the moon to the sun, the sky lighten up the moment I phushed the butten:)

Thank you again Imar!:)



Salute
www.Wimp.no
www.Spotify.com
Hot band= Asia & Boston






Yes it's saturday and I have something in the glas:)
Weekend whitout wife and kids:)
I call it Webweekend:)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
set image on <asp:Image> stored in DataBase myself.panku ASP.NET 2.0 Professional 1 August 11th, 2008 10:41 AM
Chapter 8, href and HRef (p. 285) roman BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 2 June 16th, 2008 10:40 AM
Work with Image cli PHP How-To 1 July 19th, 2005 06:04 PM



All times are GMT -4. The time now is 07:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.