Image Button and Show/Hide Panel

Discussion in 'ASP .Net' started by Shapper, Sep 21, 2005.

  1. Shapper

    Shapper Guest

    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
     
    Shapper, Sep 21, 2005
    #1
    1. Advertising

  2. Shapper

    Guest

    <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';
    }
    }
     
    , Sep 21, 2005
    #2
    1. Advertising

  3. Shapper

    clintonG Guest

    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/




    "Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
    news:%...
    > 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
    >
     
    clintonG, Sep 21, 2005
    #3
  4. Shapper

    Guest

    I wouldnt go to server to toggle an image .. javascript could do it.
     
    , Sep 21, 2005
    #4
  5. Shapper

    Shapper Guest

    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

    "" <> wrote in message
    news::

    > I wouldnt go to server to toggle an image .. javascript could do it.
     
    Shapper, Sep 21, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jef
    Replies:
    1
    Views:
    4,444
    Steve C. Orr [MVP, MCSD]
    Mar 21, 2005
  2. John Blair
    Replies:
    1
    Views:
    637
  3. Nathan Sokalski
    Replies:
    2
    Views:
    1,050
    Nathan Sokalski
    Oct 13, 2006
  4. TJS

    show hide image button

    TJS, Nov 8, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    572
  5. Nathan Sokalski

    Design View when using an ASP:Panel to show/hide groups of <tr>'s

    Nathan Sokalski, Oct 12, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    214
    Nathan Sokalski
    Oct 13, 2006
Loading...

Share This Page