Image Button and Show/Hide Panel

S

Shapper

Hello,

I have an image button in a web page.

The default image is ShowPanel.gif.

When the image is clicked I want the panel "myPanel" to become visible
and the image button to change to HidePanel.gif.

When the image is clicked again now the panel becomes invisible and the
image gets back to ShowPanel.gif.

I have been playing with commandname, commandargument and oncommand
properties but I haven't been able to make this work.

Can someone help me out?

Thanks,
Miguel
 
S

sreejith.ram

<img id=img1 name=img1 src=''ShowPanel.gif' onclick ='toggle();' >

this is psudo code. Apply correct syntax

function toggle()
{
if(img1.src=''ShowPanel.gif' )
{
img1.src = 'HidePanel.gif';
myPanel.style.display = '';
}
else
{
img1.src = 'ShowPanel.gif';
myPanel.style.display = 'none';
}
}
 
C

clintonG

Properties can be toggled on and off in the ImageButton click event noting
I'm writing the following on the fly...

// C#
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if(ImageButton1.ImageUrl == "~/Images/ShowPanel.gif")
{
myPanel.Visible = true;
ImageButton1.ImageUrl = "~/Images/HidePanel.gif";
}
else
{
myPanel.Visible = false;
ImageButton1.ImageUrl = "~/Images/ShowPanel.gif";
}
}

// VB
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
ImageClickEventArgs)
If ImageButton1.ImageUrl = "~/Images/ShowPanel.gif" Then
myPanel.Visible = True
ImageButton1.ImageUrl = "~/Images/HidePanel.gif"
Else
myPanel.Visible = False
ImageButton1.ImageUrl = "~/Images/ShowPanel.gif"
End If
End Sub

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/
 
S

Shapper

Sorry,

I forgot to say something which makes this much more complicated.

All this is inside a Datagrid!

So when I am displaying 10 records I will have 10 buttons and 10 panels
which I need to hide/show when the correspondent button is pressed.

Any idea how to sort this out?

I have seen this in many web sites.

Thanks,
Miguel
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top