troubleshooting Question

How to load different data after a Postback

Avatar of mpdillon
mpdillon asked on
ASP.NETVisual Basic.NET.NET Programming
3 Comments1 Solution93 ViewsLast Modified:
I have a web page that displays product categories. When the user clicks on a Product Category, I want the same web page to display Product Information rather than Category information.

Here is what I see:
Initial page load

Private Sub SidePanel1_Init(sender As Object, e As EventArgs) Handles Me.Init
        LoadCategories()
    End Sub

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

        If Not IsPostBack Then
            LoadCategoryListBox()
            'LoadAllCategories()
        End If
End Sub

"LoadCategories" loads images that are buttons in the code behind file on the initial page load. This works fine.

Next a user would click on an Category image button. This would return the Category ID and from that ID I can return all the Product images for that Category. I want those images to appear on this page. The end result would be this page displaying only Product images and not any category images.

Here is what I see when a user clicks on a Category Image. The code for the "Init" event fires, then the "Page_Load" and finally the "ImageButton_Click" event fires. I have the code to load the product images located in the "ImageButton_Click" event. I have that code in that event because the button click event returns the ID number for the category which was clicked.

Here is the current sequence:
Private Sub SidePanel1_Init(sender As Object, e As EventArgs) Handles Me.Init
        ' LoadProductImages()
        LoadCategories()
    End Sub

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

        If Not IsPostBack Then
            LoadCategoryListBox()
            'LoadAllCategories()
        End If
End sub
Protected Sub ImageButton_click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
        Dim s As String = String.Empty
        Dim ib As ImageButton = DirectCast(sender, ImageButton)
        s = ib.ID
        s = Mid(s, 8, Len(s))
        If IsNumeric(s) Then
            PublicVariables.CategeryIDNoIntegerP = Val(s)
            If PublicVariables.CategeryIDNoIntegerP = 0 Then
                LoadCategories()
            Else
                LoadProductImages()
            End If
        Else
            PublicVariables.CategeryIDNoIntegerP = 0
            LoadCategories()
        End If
        '

    End Sub

How can I arrange the code so that when a user clicks on a Category Image, the page refreshes with the Products for that category?
Thanks,
pat
ASKER CERTIFIED SOLUTION
mpdillon

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros