Noddy guide to plugging a User Control into Umbraco
I have a bunch of code and user controls from other sites and projects and I'd like to use some of them in Umbraco. I have searched around here, but I can't find much of a way in.
I'm using the latest version of Umbraco - 6.something.
I have lots of user controls, so I'm hoping I can just "lift and shift" the control and maybe the registration line across, then just run the thing. But I can't even work out where to put the control.
Is there documentation anywhere that tells me how to do this please?
thanks - I tried the TV, but the video was so slow and wanted to tell me how to write user controls - I know all that stuff, I just want to deploy them to umbraco.
Ok, I'll stick them in the usercontrols folder and google the macro thing down - thanks.
I'm not sure what you mean by 'google the macro thing down'? You just need to select them from the Usercontrol dropdown once you've created a new macro.
Unless you want to pull in Umbraco content into your user-controls, you don't need to go down the Macro route. Just insert them using <%Register%> declarations:
That's cool - I thought that should work, but didn't want to thrash around trying too much... I'll give that a go. Thanks
-- later...
That works fine, I can put code in the template (master page) files that way, and my user controls work, supported by some associated code in App_Code. I just cut and pasted the stuff from another site, dropped it in there as you suggested and it's all good.
I also tried the macro route (following this video here: http://www.nibble.be/screencasts/Addingcustomusercontrols.htm), and worked out how to get the macro to show up on the wysiwg editor : you have to tick a dialog box to make it show up there. That doesn't work in Medium Trust, well I think it's a trust issue as when it runs I get a security violation.
So I think I can put user controls in the templates, but not in the actual content, in my Medium Trust deployment environment. Anyone knows different, please shout! I can work around "user controls can't be inserted by content editors" if I have to, but it would be better to allow them to insert these if I can.
philw, did you ever find a way to insert a user control-based macro into a content page? I'm having the same issue in umbraco 6. I'm also using MVC instead of web forms so I'm not sure if it's even possible to use a user control macro
Create a macro and point it at the user control (there are dialog box options for that).
In practice I found that this wasn't great as I can't render the controls in the UI (I'm on Medium Trust), so I went a different way and equipped my pages with "content" fields which specify which user controls to include in each page. I parse those "content" fields and inject the user controls from C# as I want. This avoids the user having to use un-rendered macros, which are clunky.
Noddy guide to plugging a User Control into Umbraco
I have a bunch of code and user controls from other sites and projects and I'd like to use some of them in Umbraco. I have searched around here, but I can't find much of a way in.
I'm using the latest version of Umbraco - 6.something.
I have lots of user controls, so I'm hoping I can just "lift and shift" the control and maybe the registration line across, then just run the thing. But I can't even work out where to put the control.
Is there documentation anywhere that tells me how to do this please?
Have you tried Umbraco TV?
Essentially you drop the usercontrols in a Usercontrols folder and then add a new macro and select the usercontrol you want from the drop down.
Rich
thanks - I tried the TV, but the video was so slow and wanted to tell me how to write user controls - I know all that stuff, I just want to deploy them to umbraco.
Ok, I'll stick them in the usercontrols folder and google the macro thing down - thanks.
I'm not sure what you mean by 'google the macro thing down'? You just need to select them from the Usercontrol dropdown once you've created a new macro.
"search for and find the instructions for inserting the macro" - which I just did, no problems with that. Should be ok now, thanks.
Hi Phil,
Unless you want to pull in Umbraco content into your user-controls, you don't need to go down the Macro route. Just insert them using <%Register%> declarations:
Cheers, Lee
That's cool - I thought that should work, but didn't want to thrash around trying too much... I'll give that a go. Thanks
-- later...
philw, did you ever find a way to insert a user control-based macro into a content page? I'm having the same issue in umbraco 6. I'm also using MVC instead of web forms so I'm not sure if it's even possible to use a user control macro
Yes, it's pretty easy - as above. From memory:
is working on a reply...