ASP.NET Menu Master Page

Hi guys

 I have weird situation that i have a home page with two hyperlinks that pass querystring to call a masterpage/contentpage site.

the masterpage has a menu and contentplaceholder. the content site fills the contents using the database. The querystring from the homepage is uses to determine which menu to display (dynamically generated)

the problem i having that when i enter the first site (siteID = 1) the corrent menu is displayed, but then go back on the browser to even manually update the url to siteID = 2, the old menu remains persistant, its doesnt refresh to the new site ID. on masterpage load event i have session(siteID) = request.querystring(siteID). using debug i have made sute teh session site is is the correct one.

can you please tell what must be happening to not make the menu refresh looking at the new site ID. the query out put is correct as well.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Raju SrivatsavayeSoftware EngineerCommented:
Where did you place your code to generate the menu on the Master page. Is it in the If not ispostback block..Can you post that..
Mayank_AgarwalAuthor Commented:
I have tried in both the cases if no ispostback and without it as well but not change.
its in the master page load event it call the sub LoadMenu.
than when i click a menu item it reads to navigate me to the right page.
I have used this method to generate sub menu dynamically.
    Protected Sub Page_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Session("SiteID") = Request.QueryString("siteID")
        'If Not IsPostBack Then  'False if its a new request, True its postback
        'End If
    End Sub
Public Sub loadMenu(ByVal siteID As Integer)
        Using myconn As New SqlConnection(connStr)
            Dim ds As New DataSet
            Dim sql As String = "select MenuId, Text, ParentID from Menu where siteID = " & siteID    'keep menuId for xml
            Dim da As New SqlDataAdapter(sql, myconn)
            ds.DataSetName = "Menus"
            ds.Tables(0).TableName = "Menu"
            Dim d As Integer = ds.Tables(0).Rows.Count
            Dim relation As New DataRelation("ParentChild", ds.Tables("Menu").Columns("MenuID"), ds.Tables("Menu").Columns("ParentID"), True)
            relation.Nested = True
            xmlDataSource1.Data = ds.GetXml
        End Using
    End Sub
    Public Sub decidePage(ByVal mID As Integer)
        Using myconn1 As New SqlConnection(connStr)
            Dim sql As String = "select Text from menu where menuID = " & mID
            Dim cmd As New SqlCommand(sql, myconn1)
            Dim mtext As String = cmd.ExecuteScalar()
            If Strings.InStr(mtext, "Contact") > 0 Then
                Response.Redirect("contactus.aspx?siteID=" & Session("siteID"))
            ElseIf Strings.InStr(mtext, "Parent") > 0 Then
                Response.Redirect("parents/page1.aspx?siteID=" & Session("siteID"))
                Response.Redirect("contentECC.aspx?siteID=" & Session("siteID"))
            End If
        End Using
    End Sub
    Protected Sub menu_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles menu.MenuItemClick
        Session("menuID") = menu.SelectedValue
    End Sub

Open in new window

Raju SrivatsavayeSoftware EngineerCommented:
try calling the databind method for the menu. You got the data into the datasource I guess. Now try calling the databind method.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Mayank_AgarwalAuthor Commented:
Did that no change
i have attached some screen shots for make the situation bit more clear.
            xmlDataSource1.Data = ds.GetXml
you will notice in the first instance when i select kallngur i get the correct menu, that I GO BACK in the browser it still shows up the same menu, then if i click Parent login section, thats the time it refreshes to the correct menu, not otherwise. i have even tried to manually type the url again but that doesnt work either.
Mayank_AgarwalAuthor Commented:
i have redone the page and this is how i achieved my dynamic menu, i forgo the XML method as it was proving to be a very unrealible and hard to debug.
using tis method is working for me so far with the only limitation that i have have one level of submenu for now, i am sure if need be it can be tweeked to get another level.
thanks to srivastavaya for your help.
....query database to get the rows from menu table to build the dataset
For Each item As DataRow In myDataSet.Tables(0).Rows
                Dim x As Integer = ManageSiteMenu.Items.IndexOf(ManageSiteMenu.FindItem(item(1).ToString))
                If item(1).ToString = "" Then
                    ManageSiteMenu.Items.Add(New MenuItem(item(2).ToString, item(0).ToString))
                    ManageSiteMenu.Items(x).ChildItems.Add(New MenuItem(item(2).ToString, item(0).ToString))
                End If

Open in new window

Mayank_AgarwalAuthor Commented:
i forgo with the xml method and used a direct method to generate menu items dynamically.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.