Copied to clipboard

Flag this post as spam?

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


  • Nick 101 posts 123 karma points
    Aug 22, 2012 @ 12:25
    Nick
    0

    Render ascx user control from razor macro in Umbraco 4.7

    I've had this problem before and never got it to work but this time I have no alternative way of going around it and really need to get this working.

    I have a simple ascx control that reads an RSS feed and outputs it in simple html. The code behind is pretty simple.

    Then I have a razor script that renders an entire page and within a certain area of that page I want to add my ascx control.

    If I add the control straight on the template like this:

    <umbraco:macro Alias="SubnavRenderer" language="cshtml" runat="server"></umbraco:macro>

    it works well but the blog entries appear outside the content.

    So from inside the razor script I do something like this:

    foreach (var item in Model.Children) 
       
    {
           
    ...
           
    else if(item.NodeTypeAlias == "Blog")
                 
    {
                   
    @Html.Raw(umbraco.library.RenderMacroContent("<?UMBRACO_MACRO macroAlias=\"BlogRenderer\"></?UMBRACO_MACRO>", Model.Id));
                 
    }
           
    }

    This renders an empty div but the content fail to render in it so the macro is half-working. I am suspecting it is connected to the lifecycle of the page. The macro has a page_load event that probably is skipped or something like that. The ascx content loads but the code behind doesn't execute so it must be a page lifecycle timing issue.

    Any ideas? Many thanks

  • Rahmathullah 7 posts 85 karma points
    Sep 15, 2014 @ 11:47
    Rahmathullah
    0

    Hi All,

    I've a problem similar to this.(may be same)

    ie;

    User controls htmls are getting rendered. but its like the page_load is not working.

     

    Please save my life.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies