Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Kurniawan Kurniawan 202 posts 225 karma points
    Oct 27, 2010 @ 03:41
    Kurniawan Kurniawan
    0

    Assign Node ID to Custom aspx page.

    Hi,

    I want to create a custom pages (aspx page) in umbraco.

    But I will extend the same master pages which I have created in umbraco.

    The only problem is "This masterpages has umbraco:item and macro in it'

    which throws me error when I open it because I don't have node ID assign to it.

    Is that possible to assign a node ID into my custom aspx page?


    Here is the error message if I use that master pages.

    [NullReferenceException: Object reference not set to an instance of an object.]
    umbraco.item..ctor(IDictionary elements, IDictionary attributes) +1091
    umbraco.presentation.templateControls.ItemRenderer.GetFieldContents(Item item) +722
    umbraco.presentation.templateControls.ItemRenderer.ParseMacros(Item item) +180
    umbraco.presentation.templateControls.ItemRenderer.Init(Item item) +39
    umbraco.presentation.templateControls.Item.OnInit(EventArgs e) +157
    System.Web.UI.Control.InitRecursive(Control namingContainer) +140
    System.Web.UI.Control.InitRecursive(Control namingContainer) +311
    System.Web.UI.Control.InitRecursive(Control namingContainer) +311
    System.Web.UI.Control.InitRecursive(Control namingContainer) +311
    System.Web.UI.Control.InitRecursive(Control namingContainer) +311
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +480

     

    Thanks

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 27, 2010 @ 04:33
    Aaron Powell
    0

    And what node ID would you pass? If the page is outside of Umbraco then Umbraco doesn't know anything about it.

    You *may* be able to fudge around with the Request object enough to fake that it's on a page, but it still begs the question of what node ID to use.

    You'd be better designing your masterpage to not require Umbraco or turning your custom page into a user control and host it inside an Umbraco page.

  • Kurniawan Kurniawan 202 posts 225 karma points
    Oct 27, 2010 @ 13:39
    Kurniawan Kurniawan
    0

    Thx slace,

    i will create a node in umbraco and grab that node id in my custom aspx page.

    is there anyway to assign it on init event of my aspx page?

    the reason i want to do this because I want to do output cache for this aspx page.
    In some reason it took sometime to open an umbraco page even in my local machine.
    I have put all caching on my xslt macro but i don't think it works.

    if i m using aspx user control and put it inside macro and set the caching on umbraco macro, do I need to put output cache inside my user control as well?

    do you know how the cache works inside the macro? Thanks so much. If i use

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 27, 2010 @ 13:50
    Aaron Powell
    1

    If you know the ID of the node that you want to load content why are you bothering with <umbraco:Item, use nodeFactory and you'll save a heck of a lot of hacking. But I'd say that your templates aren't well designed if you want to use them for non-Umbraco pages but have Umbraco content loading into them.

    Also, I wouldn't try and use <umbraco:Macro on a page which isn't an Umbraco page, you're also going to end up with problems.

    Macro caching isn't using output caching (from what I recall), it stores in memory the result of invoking the macro code. This is most common with XSLT and DLR scripts since they (generally) don't have server interaction. Caching .NET components can be harder as you have to worry about server events, etc.

    With the Init method of the ASP.NET life cycle, that fires on anything which inherits from System.Web.UI.Control, so you can put it on the code behind for a masterpage, an aspx page, etc.

  • Kurniawan Kurniawan 202 posts 225 karma points
    Oct 28, 2010 @ 09:10
    Kurniawan Kurniawan
    0

    It's because <umbraco:Item> is used in my master page, for getting the title or navigation for example.

    I don't want to duplicate my master pages for my custom pages because it has a duplication.

     

    I guess I will go with (user controls) solution and put output cache on that user control.

    But just currious, Is there any way to assign node ID in my custom pages, so that I can use master pages which has <umbraco:item> ?

     

    Which on is faster using user control macro or XSLT macro ?

    XSLT is easier for navigation, etc.. But it seems it is very slow and I can see lagging when the page is loading.
    Is XSLT good to have if you need to have a quick website ? Isn't do too much looping on umbraco.config if I have many xslt macro ?

     

    Thanks for your help.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 28, 2010 @ 13:07
    Aaron Powell
    0

    If you wrap the <umbraco:Item in a <asp:Content you can choose to replace that on your custom pages which will remove the Umbraco item from it.

    There's no answer to the "what's faster", choose the best one for your needs. Don't prematurely optimize a site, that'll be doomed to failure.

  • Kurniawan Kurniawan 202 posts 225 karma points
    Oct 28, 2010 @ 14:35
    Kurniawan Kurniawan
    0

    Thanks slace, but the problem ia , i don't want to replace or rewrite that umbraco item/macro functionality.

    I want to reuse my umbraco macro navigation xslt function in my custom pages.

    is there a way to do it?

    thanks

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 28, 2010 @ 22:52
    Aaron Powell
    0

    No you can't, there's no Umbraco Current Page object so it isn't available in the XSLT.

Please Sign in or register to post replies

Write your reply to:

Draft