Click in Image to open Link?

M

Miguel Dias Moura

Hello,

i have an image with the following code:
<img src="image/panel.gif" width="20" height="80"
onClick="fnLoadNewWindow('http://www.google.com');">

When i click the image the Javascript Function fnLoadNewWindow opens a new
window with google.com.

The problem is that the mouse doesn't change when it's over the image to the
icon that usually shows when the image is a link.

What am i doing wrong here?

Thank You,
Miguel

P.S: The function works fine. A new windows is opened when i click the
image.
 
K

Ken Cox [Microsoft MVP]

Hi Miguel,

An ASP.NET Imagebutton control would give you the effect you want:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
ImageButton1.Attributes.Add _
("onclick", _
"window.open('http://www.google.com',null," & _
"'height=200,width=400," & _
"status=yes,toolbar=no,menubar=no," & _
"location=no');return false;")
End Sub


<form id="Form1" method="post" runat="server">
<asp:ImageButton id="ImageButton1" runat="server"
ImageUrl="http://www.google.ca/intl/fr_ca/images/logo.gif"></asp:ImageButton>
</form>

Ken
Microsoft MVP [ASP.NET]
 
M

Miguel Dias Moura

There is a problem. I allready have a form in this page. Can i have 2 forms
in the same page?

I am asking this because i got an error.

Miguel

Ken Cox said:
Hi Miguel,

An ASP.NET Imagebutton control would give you the effect you want:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
ImageButton1.Attributes.Add _
("onclick", _
"window.open('http://www.google.com',null," & _
"'height=200,width=400," & _
"status=yes,toolbar=no,menubar=no," & _
"location=no');return false;")
End Sub


<form id="Form1" method="post" runat="server">
<asp:ImageButton id="ImageButton1" runat="server"
ImageUrl="http://www.google.ca/intl/fr_ca/images/logo.gif"></asp:ImageButton

</form>

Ken
Microsoft MVP [ASP.NET]


Miguel Dias Moura said:
Hello,

i have an image with the following code:
<img src="image/panel.gif" width="20" height="80"
onClick="fnLoadNewWindow('http://www.google.com');">

When i click the image the Javascript Function fnLoadNewWindow opens a new
window with google.com.

The problem is that the mouse doesn't change when it's over the image to
the
icon that usually shows when the image is a link.

What am i doing wrong here?

Thank You,
Miguel

P.S: The function works fine. A new windows is opened when i click the
image.
 
K

Ken Cox [Microsoft MVP]

Generally speaking, you can only have one form in an asp.net page. Perhaps
you can show the code that you are trying to make work? It would be easier
to give advice.

Miguel Dias Moura said:
There is a problem. I allready have a form in this page. Can i have 2
forms
in the same page?

I am asking this because i got an error.

Miguel

Ken Cox said:
Hi Miguel,

An ASP.NET Imagebutton control would give you the effect you want:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
ImageButton1.Attributes.Add _
("onclick", _
"window.open('http://www.google.com',null," & _
"'height=200,width=400," & _
"status=yes,toolbar=no,menubar=no," & _
"location=no');return false;")
End Sub


<form id="Form1" method="post" runat="server">
<asp:ImageButton id="ImageButton1" runat="server"
ImageUrl="http://www.google.ca/intl/fr_ca/images/logo.gif"></asp:ImageButton

</form>

Ken
Microsoft MVP [ASP.NET]


Miguel Dias Moura said:
Hello,

i have an image with the following code:
<img src="image/panel.gif" width="20" height="80"
onClick="fnLoadNewWindow('http://www.google.com');">

When i click the image the Javascript Function fnLoadNewWindow opens a new
window with google.com.

The problem is that the mouse doesn't change when it's over the image
to
the
icon that usually shows when the image is a link.

What am i doing wrong here?

Thank You,
Miguel

P.S: The function works fine. A new windows is opened when i click the
image.
 
C

chad [email at] gosigma.com

You might try using a hyperlink instead. You can specify the image uri
for the link to use, plus the navigate url, plus the target of "_blank".
E.g,

<asp:HyperLink id="HyperLink1" runat="server" NavigateUrl="Search.aspx"
ImageUrl="search.jpg" Target="_blank">Search</asp:HyperLink>

or in html,

<a id="HyperLink1" href="Search.aspx" target="_blank">
<img src="search.jpg" alt="Search" />
</a>

HTH,

Chad
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top