Copied to clipboard

Flag this post as spam?

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


  • David Capparelli 2 posts 82 karma points
    Nov 18, 2016 @ 13:56
    David Capparelli
    0

    Umbraco 7 (MVC) + Uskinned + User Controls

    Hi - i am working on converting a traditional .NET website to Umbraco 7 and am using uSkinned theme kit. For the most part the website is pretty straightforward but there are several pages that today retrieve data from a backend (excel, ms access, etc). Through various searches here in the forum and on the web i got the impression i could create a traditional usercontrol (ascx) and use it via the developer/macro section of umbraco. I tried to create a very simple usercontrol with a textbox, label and button.. When the button is clicked what is in the text is copied to the label. I copied the dll and ascx to the necessary umbraco folders and added it to a richtextbox. Although it renders, the code behind does not fire. I don't know what i am doing wrong... or is this a case that user controls will not work in MVC. and if so does anyone have current examples that can help? thanks.

    PS: i am a dev but am still pretty green in Umbraco, uSkinned and MVC... so apologies beforehand if i missed an answer to this somewhere in this forum.

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Nov 30, 2016 @ 23:31
    Alex Skrypnyk
    0

    Hi David,

    UserControll should work as usual, but of course you need to wrap it to macro.

    Maybe you can't debug it? Or it's not working at all?

    Thanks,

    Alex

  • David Capparelli 2 posts 82 karma points
    Dec 01, 2016 @ 14:14
    David Capparelli
    0

    Hi Alex - thanks for getting back to me.. i did wrap it in a macro.. and debugged it and the events just didn't fire.. In any case, i ended up focusing my attention on understanding SurfaceControllers and was able to implement all i had to using SurfaceControllers in the end. forgot to mark this post as solved!!!

  • Rick Mason 38 posts 169 karma points
    Dec 02, 2016 @ 13:40
    Rick Mason
    100

    For anyone who finds this from a search, we have migrated usercontrols running on Umbraco templates including the events. We didn't use macros. In our case the controls are always part of the template, so they're placed directly on the template.

    The usercontrol.asax.cs just needs to be changed to inherit from System.Web.Mvc.ViewUserControl<T> rather than System.Web.UserControl.

    T in this case is the type of the model in your razor view.

    On the razor view you reference it just like any other partial:

    @Html.Partial("~/views/MyUserControl.ascx", Model)

Please Sign in or register to post replies

Write your reply to:

Draft