3 Replies - 9737 Views - Last Post: 23 February 2011 - 11:29 PM Rate Topic: -----

#1 Grant@Liquid8  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 23-February 11

Change image button onclick

Posted 23 February 2011 - 03:14 AM

Hi, I'm working with VB.Net. I need to know how to change the ImageButton in the Master page onclick, eg:
When the blue home button is clicked, the home button must appear red (this would obviously be a separate image) on the home page.

Thanks in advance :)
Is This A Good Question/Topic? 0
  • +

Replies To: Change image button onclick

#2 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 446
  • View blog
  • Posts: 1,501
  • Joined: 28-April 09

Re: Change image button onclick

Posted 23 February 2011 - 05:34 AM

what have you tried so far?
Was This Post Helpful? 0
  • +
  • -

#3 sam.bengtson  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 58
  • Joined: 21-February 11

Re: Change image button onclick

Posted 23 February 2011 - 10:07 PM

<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/images/aspx.gif" onclick="ImageButton1_Click />

im not sure how it works in VB but in C# you would go something like

protected void ImageButton1_Click(Object sender, EventArgs e)
{
ImageButton1.ImageUrl = "url of your new image";

}

I imagine that the code is similar for VB
Was This Post Helpful? 0
  • +
  • -

#4 Guest_grant&Liquid8*


Reputation:

Re: Change image button onclick

Posted 23 February 2011 - 11:29 PM

Thanks for your posts guys!

Sam, I tried that method but it didn't seem to work, anyway, what I eventually did
was create a Roll over method in the main form, which wasn't my intention but I was given the green light to do it


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        load_mouse_events()
    End Sub

    Private Sub load_mouse_events()
        ImageButtonHome.Attributes.Add("onmouseover", "src='Images/Home_red.jpg'")
        ImageButtonHome.Attributes.Add("onmouseout", "src='Images/Home1.jpg'")
    End Sub




Thanks again :)
Was This Post Helpful? 0

Page 1 of 1