I wanted to be able to use a custom .NET control directly in one of my master pages but it seemed that the only way I could get it to work was as an Umbraco macro.
i.e. I had created a user control and I wanted to use it in a master page via mark-up either by registering the control with an @Register tag on the master page or by adding the control in the 'pages > controls' section in web.config. But trying those approaches, the control was not successfully added to the page. Only after creating a macro from the control and the using the macro could I get it onto the masterpage. In this case it seems that the Umbraco macro is being a bit of an uneccessary middle-man since the control that I made is not intended to be used in the richtext editor.
So is it possible to use a custom .net control directly in this way or do they always have to be converted into macros to be used?
It is totally possible to put a control directly on your masterpages without wrapping in a Macro. As they are just standard masterpages they should just work and I have done this many times in the past when I do not need to wireup with Umbraco features. So it appears that you may have other problems with your configuration that are not obvious from your description above.
The advantages of using a Macro are as you say already, the ability to insert them into the RTE, pass Macro Parameters (Page properties etc) without needing to make uneccessary API calls from your usercontrol, and to take advantage of the built in caching in Umbraco.
Using plain (non-macro) .net control
Hi,
I wanted to be able to use a custom .NET control directly in one of my master pages but it seemed that the only way I could get it to work was as an Umbraco macro.
i.e. I had created a user control and I wanted to use it in a master page via mark-up either by registering the control with an @Register tag on the master page or by adding the control in the 'pages > controls' section in web.config. But trying those approaches, the control was not successfully added to the page. Only after creating a macro from the control and the using the macro could I get it onto the masterpage. In this case it seems that the Umbraco macro is being a bit of an uneccessary middle-man since the control that I made is not intended to be used in the richtext editor.
So is it possible to use a custom .net control directly in this way or do they always have to be converted into macros to be used?
Thanks.
Hi Bob
It is totally possible to put a control directly on your masterpages without wrapping in a Macro. As they are just standard masterpages they should just work and I have done this many times in the past when I do not need to wireup with Umbraco features. So it appears that you may have other problems with your configuration that are not obvious from your description above.
The advantages of using a Macro are as you say already, the ability to insert them into the RTE, pass Macro Parameters (Page properties etc) without needing to make uneccessary API calls from your usercontrol, and to take advantage of the built in caching in Umbraco.
Peter
is working on a reply...