Copied to clipboard

Flag this post as spam?

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


  • Jedd France 29 posts 140 karma points
    Apr 30, 2016 @ 14:42
    Jedd France
    0

    Switching from MVC to Webforms in Umbraco 7.4.2

    Hello everyone,

    I have been using Umbraco for a few years and have always used Webforms. After avoiding Umbraco 7 for a while, I decided to move with the times and use it for a new website I am building. Umbraco 7.4.2 was the latest release and when I installed it, the automatic rendering engine was MVC. I struggled to get it switched to Webforms so I stuck with it. Now I'm occurring issues because I need to use usercontrols but this obviously requires Webforms.

    Can anyone give me some advice as to what I need to do to switch to Webforms?

    I have already changed the rendering engine to Webforms in the umbracoSettings file, I just need some help changing the code on my templates to work with Webforms.

    This is the code for my masterpage:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
    }
    
    <!DOCTYPE html>
    <html lang="en">
        <head>
    
            <!------ STYLESHEET REFERENCES ------>
            <link rel="stylesheet" href="~/css/styles.css" />
            <link rel="stylesheet" href="~/css/site-layout.css" />
            <link rel="shortcut icon" href="~/favicon.ico" />
    
            <!------ FONT REFERENCES ------>
            <link href='https://fonts.googleapis.com/css?family=Rubik:400,700,400italic' rel='stylesheet' type='text/css'>
    
            <!------ JAVASCRIPT REFERENCES ------->
    
    
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
    
    
    
            <title>Home</title>
        </head>
        <body>
            <header>
                <a href="/"><img src="/images/mobile-logo.png" class="mobileLogo" /></a>
                <a href="/"><img src="/images/desktop-logo.png" class="desktopLogo" /></a>
                <img src="/images/menu-icon.png" class="menuIcon" />
                <div id="top-nav">
                    @Umbraco.RenderMacro("TopNav")
                </div>
            </header>
            <div id="header-panel-bg">
                <div id="header-panel-inner">
                    @Umbraco.Field("headingText");
                </div>
            </div>
            @RenderBody()
            <div id="footer">
                <img class="footerPhone" src="/images/icons/phone-icon.png" /><p>01324 825665</p>
                <img class="footerEmail" src="/images/icons/email-icon.png" /><p>[email protected]</p>
                <p class="copyright"><span class="red">©</span>Ryan Autocare 2016</p>
            </div>
        </body>
    </html>
    

    I'm pretty comfortable with Webforms so I know how to change my Macro code, it's mostly just the code at the very top that inherits stuff?

    Any help would be greatly appreciated.

    Thank you, Jedd

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Apr 30, 2016 @ 16:56
    Nicholas Westby
    101

    I don't think you can convert an Umbraco template between MVC/web forms. What you can do is create a new template (use a different name, or issues may arise) and it should be a web forms template now that you've modified the configuration (assuming you've modified the correct configuration).

    When you create the new template, it should have a bit of sample code for web forms that should get you started.

    Before you do that, however, here are some notes:

    • I think you actually can use user controls in MVC. If you wrap that user control in a macro, I think Umbraco is smart enough to use it in MVC (there are some limitations related to postbacks).
    • Are you sure you actually need user controls? Why not user partial views in MVC?
    • You can make just as complicated sites in MVC as you could in web forms. Here's an example: https://nvisioncenters.com/

    Here is some documentation that may help you:

  • Jedd France 29 posts 140 karma points
    May 04, 2016 @ 10:05
    Jedd France
    0

    Hi Nicholas,

    Thank you very much for the information. I'll look through the links you supplied and see which rendering engine I prefer.

    Thanks again, Jedd

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    May 04, 2016 @ 10:15
    Sebastiaan Janssen
    0

    Just note that forms in usercontrols will not work, but yes, other than that you can wrap usercontrols in macros.

    I've also blogged about converting from a Webforms form to MVC form here: https://umbraco.com/follow-us/blog-archive/2013/7/14/moving-from-webforms-to-mvc/

  • Fernanda Bernardes 27 posts 147 karma points
    May 05, 2016 @ 12:12
    Fernanda Bernardes
    0

    Sebastiaan, have a nice day (or night??)!!

    I post in forum a question about your post quoted above. (https://our.umbraco.org/forum/templates-partial-views-and-macros/77062-partial-views-with-parameters).

    Could you help-me? I believe that will help this member too.

    Thanks!!!

Please Sign in or register to post replies

Write your reply to:

Draft