Help with ImageButton (clicking more than once)

Vetrijar

Regular
Joined
Sep 1, 2003
Messages
55
Location
Texas
Please help...

I'm like basically all done with the website but this part is really getting to me.


I have a page that has a imagebutton linked to a category change function. When the user clicks the picture, it will change the picture and switch the display to show different data. when the user clicks the picture again, it will change the picture back to what it was, and the data will be switched to. Basically it's for switching between a couples and singles data list for a personals web site.

What happens is after the first switch, I cannot switch back!! After maybe 10 clicks, the program switches back. Is there a problem with buffer or something? or postback to the same webpage ?? It's like the button works once and then stops executing again.
 
Found how to format.. :D

Visual Basic:
    Private Sub ProfileBanner_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ProfileBanner.Click
        Session("SearchFilter") = "" ' Reset
        If Session("ViewWho") = "Single" Then
            ' Single change to Couple
            Session("SetView") = "Couple"
            Response.Redirect("personals.aspx")  ' Reload
        Else
            ' Couple Change to Single
            Session("SetView") = "Single"
            Response.Redirect("personals.aspx")  ' Reload
        End If
    End Sub

===== Below the page load of that personals.aspx =====

Visual Basic:
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim Pg As Integer = 1, temp As String
        Dim name As String = Page.Request.Item("usr")

        If Session("SearchFlag") = "ON" Then
            Session("SearchFlag") = ""
        Else
            If Not Page.IsPostBack Then
                ' First time page is clicked on
                Session("SearchFilter") = "" ' Reset
                Session("ViewWho") = "Single" ' Reset View back to Singles
            End If
        End If

        If Session("SetView") = "Couple" Then
            ' Couple Search
            Session("ViewWho") = "Couple"
        Else
            ' Single Search Visible
            Session("ViewWho") = "Single"
        End If
        Session("SetView") = ""

        If Session("ViewWho") = "Couple" Then
            ' Currently viewing couple section
            ProfileBanner.ImageUrl = "images/prof_Lbanner_s.jpg" ' show singles banner
            ProfileBanner.ToolTip = "View the Singles"
        Else
            ' Currently viewing singles section
            ProfileBanner.ImageUrl = "images/prof_Lbanner_c.jpg" ' show couples banner
            ProfileBanner.ToolTip = "View the Couples"
        End If


The picture changes once. Then it stops changing. If I click the
picture several times (10 times or such) it will finally change again.
 
The thing is that you're setting it in the Click event and th Page Load, both events are fired when you click the button.
You should limit the toggle effect to the click event.
 
Back
Top