In my MasterPage I have implemented the ItemDataBound event to try and set the title of each page that implements the master page dynamically but for some reason the title is not being set.
I also tried doing it in the ItemCreated event but still did not work.
If I set the title in the Web.sitemap then it works perfectly but when I set it using
e.Item.SiteMapNode.Title = CurrentNodeTitle; the title is nto being set.
If I add those two statements there I get the following error: ( Request is not available in this context ) ( Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about
the error and where it originated in the code. ) ( Exception Details: System.Web.HttpException: Request is not available in this context ) ( Source File: ...\Global.asax.cs )
Thanks for all your help, the project is over 150MB and I have a slow dsl connection so it's hard for me to upload this, what exactly did you do to make it work for you? The SiteMapPath is in the Master Page so I need to set the Title of the Sitemap in the
Master Page.
skyxn3t
Member
1 Points
19 Posts
How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 18, 2012 03:00 AM|LINK
In My Web.sitemap I have the following:
<siteMapNode url="~/Groups/ViewGroups.aspx" urlRoute="groups/{PostId}/{PostTitle}" /> </siteMapNode>In my MasterPage I have implemented the ItemDataBound event to try and set the title of each page that implements the master page dynamically but for some reason the title is not being set.
protected void SiteMapPath1_ItemDataBound(object sender, SiteMapNodeItemEventArgs e) { string CurrentNodeTitle = GetTitleFromDatabase(); if (e.Item.ItemType == SiteMapNodeItemType.Current) { e.Item.SiteMapNode.Title = CurrentNodeTitle; } }
I also tried doing it in the ItemCreated event but still did not work.
If I set the title in the Web.sitemap then it works perfectly but when I set it using e.Item.SiteMapNode.Title = CurrentNodeTitle; the title is nto being set.
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 23, 2012 03:28 AM|LINK
Try to add the sentence below:
SiteMap.Provider.CurrentNode.ReadOnly = false;
Feedback to us
Develop and promote your apps in Windows Store
skyxn3t
Member
1 Points
19 Posts
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 23, 2012 06:43 AM|LINK
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 23, 2012 07:53 AM|LINK
Modify current node title in Global.asax file
void Application_Start(object sender, EventArgs e) { SiteMap.Provider.CurrentNode.ReadOnly = false; SiteMap.Provider.CurrentNode.Title = "CurrentNodeTitle"; }Feedback to us
Develop and promote your apps in Windows Store
skyxn3t
Member
1 Points
19 Posts
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 23, 2012 02:19 PM|LINK
skyxn3t
Member
1 Points
19 Posts
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 23, 2012 10:52 PM|LINK
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 24, 2012 01:54 AM|LINK
It works for me. Can you go to the link below and share your project for my test?
https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=1345168118&rver=6.2.6289.0&wp=MBI_SSL_SHARED&wreply=https:%2F%2Fskydrive.live.com%2F&lc=2052&id=250206&mkt=zh-CN&cbcxt=sky
Remember to provide your shared links.
You can also send mail to me: support-v-franj@hotmail.com
Thanks
Feedback to us
Develop and promote your apps in Windows Store
skyxn3t
Member
1 Points
19 Posts
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 24, 2012 10:02 PM|LINK
Thanks for all your help, the project is over 150MB and I have a slow dsl connection so it's hard for me to upload this, what exactly did you do to make it work for you? The SiteMapPath is in the Master Page so I need to set the Title of the Sitemap in the Master Page.
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: How to Set the SiteMapNode Title Dynamically from Master Page ? ASP.NET
Aug 27, 2012 03:28 AM|LINK
Check the following url,
http://forums.asp.net/t/1590425.aspx
Hope this helps
Feedback to us
Develop and promote your apps in Windows Store