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.
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!!!
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:
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.
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
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!!!
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 thanSystem.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)
is working on a reply...