Reaching SiteMap.CurrentNode on Default.aspx (where pageId is not defined)

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/16/2008 4:09:53 AM
Gravatar
Total Posts 11

Reaching SiteMap.CurrentNode on Default.aspx (where pageId is not defined)

Hi,
Does anyone know how you reach SiteMap.CurrentNode on Default.aspx (when pageid is not defined). When pageId is 0 everything is OK and Sitemap is populated as usual, but not when pageid isn't set. I need it to set the "page last updated" using:

  private void Page_Load(object sender, System.EventArgs e)
  {
   try
    {
            mojoSiteMapNode mojoNode = (mojoSiteMapNode)SiteMap.CurrentNode;
            Label3.Text = mojoNode.LastModifiedUtc.ToString();
    }
    catch (Exception ex)
    {
      // ...
    }
  }

My best idea is to do a 301 redirect from Default.aspx to Default.aspx?pageid=0 to make sure we don't have any duplicated content. But this seems.. well.. off

6/16/2008 6:05:48 AM
Gravatar
Total Posts 18439

Re: Reaching SiteMap.CurrentNode on Default.aspx (where pageId is not defined)

You don't need to use SiteMap nodes for this. If you page inherits from mojoBasePage, you can do this:

if(CurrentPage != null)
{
lastModified.Text = CurrentPage.LastModifiedUtc.ToString();
}

If you're not using mojoBasePage, you can get current page with:

using mojoPortal.Business.WebHelpers;

PageSettings currentPage = CacheHelper.GetCurrentPage();

Hope it helps,

Joe

6/16/2008 9:00:06 AM
Gravatar
Total Posts 11

Re: Reaching SiteMap.CurrentNode on Default.aspx (where pageId is not defined)

Thank you very much! Worked like a charm, using code:

            PageSettings currentPage = CacheHelper.GetCurrentPage();
            if(currentPage != null)
                {
                LastModified.Text = currentPage.LastModifiedUtc.ToString();
                }

You must sign in to post in the forums. This thread is closed to new posts.