Image Button and Show/Hide Panel

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shapper

    Image Button and Show/Hide Panel

    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

  • sreejith.ram@gmail.com

    #2
    Re: Image Button and Show/Hide Panel

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

    this is psudo code. Apply correct syntax

    function toggle()
    {
    if(img1.src=''S howPanel.gif' )
    {
    img1.src = 'HidePanel.gif' ;
    myPanel.style.d isplay = '';
    }
    else
    {
    img1.src = 'ShowPanel.gif' ;
    myPanel.style.d isplay = 'none';
    }
    }

    Comment

    • clintonG

      #3
      Re: Image Button and Show/Hide Panel

      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_Cl ick(object sender, ImageClickEvent Args e)
      {
      if(ImageButton1 .ImageUrl == "~/Images/ShowPanel.gif")
      {
      myPanel.Visible = true;
      ImageButton1.Im ageUrl = "~/Images/HidePanel.gif";
      }
      else
      {
      myPanel.Visible = false;
      ImageButton1.Im ageUrl = "~/Images/ShowPanel.gif";
      }
      }

      // VB
      Protected Sub ImageButton1_Cl ick(ByVal sender As Object, ByVal e As
      ImageClickEvent Args)
      If ImageButton1.Im ageUrl = "~/Images/ShowPanel.gif" Then
      myPanel.Visible = True
      ImageButton1.Im ageUrl = "~/Images/HidePanel.gif"
      Else
      myPanel.Visible = False
      ImageButton1.Im ageUrl = "~/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/




      "Shapper" <mdmoura*NOSPAM *@gmail.*DELETE 2SEND*com> wrote in message
      news:%23KCXbDrv FHA.2792@tk2msf tngp13.phx.gbl. ..[color=blue]
      > 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
      >[/color]


      Comment

      • sreejith.ram@gmail.com

        #4
        Re: Image Button and Show/Hide Panel

        I wouldnt go to server to toggle an image .. javascript could do it.

        Comment

        • Shapper

          #5
          Re: Image Button and Show/Hide Panel

          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

          "sreejith.ram@g mail.com" <sreejith.ram@g mail.com> wrote in message
          news:1127317588 .776514.270290@ g44g2000cwa.goo glegroups.com:
          [color=blue]
          > I wouldnt go to server to toggle an image .. javascript could do it.[/color]

          Comment

          Working...