Copied to clipboard

Flag this post as spam?

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


  • Michal Neuwirth 3 posts 23 karma points
    Jan 27, 2014 @ 15:26
    Michal Neuwirth
    0

    Combining WebForms and Razor macros - deep dive

    I'm quite new in Umbraco and I'm pleasantly surprised, that I can have webforms pages with Razor macros.

    I'm looking for more deep details about this implementation.

    • How Umbraco did solve the combination of Razor macros inside the WebForms?
    • Are there any known issues with this combination?
    • Are there any limitation of this combinations?

    Thx.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 28, 2014 @ 17:08
    Jeavon Leopold
    1

    Hi Michal,

    An additional bit of information for you is that from v4.10 onwards it is recommend that you use Partial View Macros (these are written in Razor also) rather than Razor Macros (these are for legacy use only)

    • How Umbraco did solve the combination of Razor macros inside the WebForms?

    By using the existing Umbraco macro engine which previously rendered XSLT, Ruby or IronPython templates

    • Are there any known issues with this combination?

    No, it is mature now, Razor Macro's were introduced in Umbraco v4.6 and superseded by Partial View Macros in v4.10

    • Are there any limitation of this combinations?

    You cannot currently have a controller (child action) for a Partial View Macro, however you can generally work around this issue.

    Jeavon

  • Michal Neuwirth 3 posts 23 karma points
    Jan 29, 2014 @ 09:04
    Michal Neuwirth
    0

    Thanks Jeavon for info!

    I was looking around to better understand Partial Views

    Are there any information about the workaround for the Partial View Macro controllers?

    I've found that my WebForm pages don't contain any ViewState. Is it still possible to use .Net User Control on WebForm pages where are used Razor Partial Views, so some features are written in Razor and another via .NET Controls?

    MN

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Jan 30, 2014 @ 18:13
    Jeavon Leopold
    0

    Hi Michal,

    One thing I would ask is why you might choose to use WebForms with Partial View Macros rather than using native MVC templates and Partial Views, is it because you have existing user controls?

    The workaround for Macro Partial Views is to just have it render a @Html.Action, it is described at the end of this blog post.

    For your WebForm template to have a View state, you just need to ensure that you have <form runat="server">in the template and ensure than any usercontrols are within that form. You can render Macro Partial Views within your WebForms templates where ever you want to.

    Jeavon

  • Amna 3 posts 23 karma points
    May 16, 2014 @ 12:26
    Amna
    0

    I am integrating my old web forms user controls in Razor macro and getting error Error executing child request for handler 'Umbraco.Web.FormlessPage'. and This page is missing a HtmlHead control which is required for the CSS stylesheet link that is being added. Please add <head runat="server" />.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 16, 2014 @ 14:40
    Jan Skovgaard
    0

    Hi Amna

    What version of Umbraco are you using? And have you set the template mode to run webforms in the /config/umbracoSettings.config ?

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft