XMLDataSource.Data not binding right
-
Hello Everybody. Its my first time using the CP forum. though I use the articles all the time... :) I have some code that builds an XML document for each user that logs in. This xml doc should become the datasource for the navigation system. I do not use the built-in membership system, but rather have my own "Users" table and do my own authentication etc. The XML Document is stored in a strongly-typed Session variable (as a public property in a class module). The property name is "CurrentMap" The problem is that setting XMLDataSource.Data to the xml snippet just doesnt work. when i log in i always see the menus belonging to the previous user which logged in. Only when continuing in the site do i see the menu items based on the current users sitemap. For testing i used the CurrentMap.Save method to save the doc to disk, and the doc is 100% correct, exactly according to my code. the problem is only on the home page, feels like asp.net is kindly doing some caching which id like to turn off. It may also be in regard to the events that I use to bind the datasource to the xmldoc, and I used quite a few of them. But maybe im just not using the right one... :sigh: This is happening on the code behind in a Master page in asp.net 3.5. here is the entire relevant codebehind file for the master page:
Partial Class IMaster Inherits System.Web.UI.MasterPage Protected Sub Page\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding CheckUser() xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml End Sub Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CheckUser() xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml xdsSiteMap.DataBind() MainMenu.DataBind() End Sub Protected Sub lkbLogout\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click ClearUser() CheckUser() End Sub Protected Sub xdsSiteMap\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles xdsSiteMap.DataBinding xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml End Sub
End Class
Here is the aspx of the master page
<td colspan="2"> <div id="MainNav" class="MainNav"> <
-
Hello Everybody. Its my first time using the CP forum. though I use the articles all the time... :) I have some code that builds an XML document for each user that logs in. This xml doc should become the datasource for the navigation system. I do not use the built-in membership system, but rather have my own "Users" table and do my own authentication etc. The XML Document is stored in a strongly-typed Session variable (as a public property in a class module). The property name is "CurrentMap" The problem is that setting XMLDataSource.Data to the xml snippet just doesnt work. when i log in i always see the menus belonging to the previous user which logged in. Only when continuing in the site do i see the menu items based on the current users sitemap. For testing i used the CurrentMap.Save method to save the doc to disk, and the doc is 100% correct, exactly according to my code. the problem is only on the home page, feels like asp.net is kindly doing some caching which id like to turn off. It may also be in regard to the events that I use to bind the datasource to the xmldoc, and I used quite a few of them. But maybe im just not using the right one... :sigh: This is happening on the code behind in a Master page in asp.net 3.5. here is the entire relevant codebehind file for the master page:
Partial Class IMaster Inherits System.Web.UI.MasterPage Protected Sub Page\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding CheckUser() xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml End Sub Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CheckUser() xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml xdsSiteMap.DataBind() MainMenu.DataBind() End Sub Protected Sub lkbLogout\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click ClearUser() CheckUser() End Sub Protected Sub xdsSiteMap\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles xdsSiteMap.DataBinding xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml End Sub
End Class
Here is the aspx of the master page
<td colspan="2"> <div id="MainNav" class="MainNav"> <
Yes. Add Page_PreRender method to the master page. This is the later in the page's life cycle than page_load. Move the databind() call to that method, see if you get the current user.
I didn't get any requirements for the signature
-
Yes. Add Page_PreRender method to the master page. This is the later in the page's life cycle than page_load. Move the databind() call to that method, see if you get the current user.
I didn't get any requirements for the signature
Hi Thank you ToddHileHoffer, I did exactly that, but the problem remains. on the landing page i get an old map. here is the current masterpage code
Protected Sub lkbLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click
ClearUser()
CheckUser()
End SubProtected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CheckUser() End Sub Protected Sub Page\_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml MainMenu.DataBind() End Sub
Please reply, i cant figure this out...
-
Hi Thank you ToddHileHoffer, I did exactly that, but the problem remains. on the landing page i get an old map. here is the current masterpage code
Protected Sub lkbLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click
ClearUser()
CheckUser()
End SubProtected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CheckUser() End Sub Protected Sub Page\_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml MainMenu.DataBind() End Sub
Please reply, i cant figure this out...
I'm sorry your page isn't working. Where are you setting the datasource for the MainMenu? Why don't you call xdsSiteMap.Databind() instead of MainMenu.Databind()? Can you debug the page and set a break point on your menu or site map and verify that the data source in the PreRender method does not match the data when the page is rendered? Another question is why are you calling CheckUser() twice? In the code above you would call CheckUser in the pageload and then agin on lkbLogout.Click(). Maybe you want to use if(!postback) in your pageload.
I didn't get any requirements for the signature
-
I'm sorry your page isn't working. Where are you setting the datasource for the MainMenu? Why don't you call xdsSiteMap.Databind() instead of MainMenu.Databind()? Can you debug the page and set a break point on your menu or site map and verify that the data source in the PreRender method does not match the data when the page is rendered? Another question is why are you calling CheckUser() twice? In the code above you would call CheckUser in the pageload and then agin on lkbLogout.Click(). Maybe you want to use if(!postback) in your pageload.
I didn't get any requirements for the signature
-
Hello Everybody. Its my first time using the CP forum. though I use the articles all the time... :) I have some code that builds an XML document for each user that logs in. This xml doc should become the datasource for the navigation system. I do not use the built-in membership system, but rather have my own "Users" table and do my own authentication etc. The XML Document is stored in a strongly-typed Session variable (as a public property in a class module). The property name is "CurrentMap" The problem is that setting XMLDataSource.Data to the xml snippet just doesnt work. when i log in i always see the menus belonging to the previous user which logged in. Only when continuing in the site do i see the menu items based on the current users sitemap. For testing i used the CurrentMap.Save method to save the doc to disk, and the doc is 100% correct, exactly according to my code. the problem is only on the home page, feels like asp.net is kindly doing some caching which id like to turn off. It may also be in regard to the events that I use to bind the datasource to the xmldoc, and I used quite a few of them. But maybe im just not using the right one... :sigh: This is happening on the code behind in a Master page in asp.net 3.5. here is the entire relevant codebehind file for the master page:
Partial Class IMaster Inherits System.Web.UI.MasterPage Protected Sub Page\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.DataBinding CheckUser() xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml End Sub Protected Sub Page\_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CheckUser() xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml xdsSiteMap.DataBind() MainMenu.DataBind() End Sub Protected Sub lkbLogout\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lkbLogout.Click ClearUser() CheckUser() End Sub Protected Sub xdsSiteMap\_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles xdsSiteMap.DataBinding xdsSiteMap.DataFile = "" xdsSiteMap.Data = CurrentMap.OuterXml End Sub
End Class
Here is the aspx of the master page
<td colspan="2"> <div id="MainNav" class="MainNav"> <
-
hi thanks for your reply in the end, my assumption was correct, the xds has an attribute called enavlecaching, i turned that off and all is good. thank you for your time and interest, it was a pleasure discussing this with you.:thumbsup:
Thank you. I've been fussing with my code, on and off, for the last few days trying to figure out why I couldn't get my string output of XML data to bind to my ListView object in .Net 3.5. I found the "onPreRender" statement in another article but a separate test datalist object bound fine in the "OnLoad" event. Turning the caching off was exactly what I needed- thanks. :laugh:
-
Thank you. I've been fussing with my code, on and off, for the last few days trying to figure out why I couldn't get my string output of XML data to bind to my ListView object in .Net 3.5. I found the "onPreRender" statement in another article but a separate test datalist object bound fine in the "OnLoad" event. Turning the caching off was exactly what I needed- thanks. :laugh: