I been working in Umbraco since last couple of years. I also been working in another CMS called EPiServer(I am not sure, if you as a reader has developed any application using EPiServer).
Still back in Umbraco 3, this did not concern me much as we created templates and stored them in db directly. I missed the code-behind feature here.
And ofcourse, Umbraco still remains my Favorite CMS.
This talk is about Creating templates:
If I need to compare this feature with EPiserver CMS 5. We need to create an .aspx page and in code-behind extend that class from TemapatePage class from EPiServer api. (And developer can take advantage of all code-behind feature and still use master pages)
Finally we need to create a document type (called Page type in EPiServer) where we specify the relative path to that .aspx page(template in EPiServer). Next is as similar as Umbraco, we go ahead by adding properties and creating pages using those document types.
On the other side in Umbraco 4, When we create a template. It creates .master file in masterpages folder and every child template is .Master file here. Which is not very conviencing at least to me. As in ASP.NET have specific uses for each of these file type(.master and .aspx).
I wish to know the reason behind,
1. Why did developers choose to go with .master file and not by .aspx and .aspx.cs files when we create a template?
2. Do we have any future plan where we will be using .aspx files as template and get to use code-behide feature?
3. Or is there any way where we use .aspx files in Umbraco (I might be unknown to this)?
Your contributions to this discussion will be appreciated.
Thank you in advance.
Regards ,
Ranjit J. Vaity
NOTE: Do not wish to be offensive toward our awesome Umbraco community by comparing 2 CMSs.
You're correct that Master and ASPX are different concepts in ASP.NET, and understanding those differences will help understand why Umbraco uses Master Pages.
A Master Page is essentially a template for .NET, defining outlying structure, global functionality, etc. This is exactly what they are in Umbraco. Although Umbraco doesn't generate a backing file and inherited class there's nothing that would stop you doing it yourself. In fact, I've done it quite a few time.
Umbraco doesn't generate actual files to represent a page, so having an ASPX is pointless, Umbraco generates its pages on the fly, not at publish time.
I wouldn't expect this to change in v5 (it wont change in v4.x) either.
You can always create custom ASPX pages which are stored outside of Umbraco, you just need to specify it as a reserved URL and Umbraco will ignore it.
I understand you point when you say we use master page for defining outlining structure. And also about reserved URLs, which is not what I wanted to do. Instead use .aspx page as a template file, where I can place my macros(usercontrols) and take advantage of code-behind. But as per your reply that cannot be the case.
I don't get why people are wanting to put functionality into the Page code behind so much, I haven't added functionality into a Page class for a very long time, and even then it's only been something like a property which is just a wrapper for a commonly used piece of code.
Using Page makes it hard to decouple code and decoupling is something that I see to be very important.
But using ASPX as a template goes against the point of introducing the Master Page in .NET 2.0. I remember using .NET 1.1 and ASPX-as-template which was just a bunch of user controls everywhere.
ASPX doesn't support UI nesting, again another reason why it's not useful as a template.
Does anyone know how I can change the master page of a master page in code? I have three umbraco templates (English.Master, German.Master and Page.Master)
In Page.Master, I have set the MasterPageFile to English.Master and that all works great. However, I have a requirement to need to change Page.Master MasterPageFile to German.Master dynamically (either as a result of a property value that the CMS editor enters or something in the query string).
I am aware in .NET that you can change the master page of an aspx page in the PreInit event, but Master pages don't have this, so am stuck.....
Any ideas on how I can acheive this without having a different Page.Master which uses the German.Master (there may be more countries added later and don't want to start the wrong way :-) )
Creating Templates in Umbraco 4
Hi All,
I been working in Umbraco since last couple of years. I also been working in another CMS called EPiServer(I am not sure, if you as a reader has developed any application using EPiServer).
Still back in Umbraco 3, this did not concern me much as we created templates and stored them in db directly. I missed the code-behind feature here.
And ofcourse, Umbraco still remains my Favorite CMS.
This talk is about Creating templates:
If I need to compare this feature with EPiserver CMS 5. We need to create an .aspx page and in code-behind extend that class from TemapatePage class from EPiServer api. (And developer can take advantage of all code-behind feature and still use master pages)
Finally we need to create a document type (called Page type in EPiServer) where we specify the relative path to that .aspx page(template in EPiServer). Next is as similar as Umbraco, we go ahead by adding properties and creating pages using those document types.
On the other side in Umbraco 4, When we create a template. It creates .master file in masterpages folder and every child template is .Master file here. Which is not very conviencing at least to me. As in ASP.NET have specific uses for each of these file type(.master and .aspx).
I wish to know the reason behind,
1. Why did developers choose to go with .master file and not by .aspx and .aspx.cs files when we create a template?
2. Do we have any future plan where we will be using .aspx files as template and get to use code-behide feature?
3. Or is there any way where we use .aspx files in Umbraco (I might be unknown to this)?
Your contributions to this discussion will be appreciated.
Thank you in advance.
Regards ,
Ranjit J. Vaity
NOTE: Do not wish to be offensive toward our awesome Umbraco community by comparing 2 CMSs.
You're correct that Master and ASPX are different concepts in ASP.NET, and understanding those differences will help understand why Umbraco uses Master Pages.
A Master Page is essentially a template for .NET, defining outlying structure, global functionality, etc. This is exactly what they are in Umbraco. Although Umbraco doesn't generate a backing file and inherited class there's nothing that would stop you doing it yourself. In fact, I've done it quite a few time.
Umbraco doesn't generate actual files to represent a page, so having an ASPX is pointless, Umbraco generates its pages on the fly, not at publish time.
I wouldn't expect this to change in v5 (it wont change in v4.x) either.
You can always create custom ASPX pages which are stored outside of Umbraco, you just need to specify it as a reserved URL and Umbraco will ignore it.
Hi Slace,
I understand you point when you say we use master page for defining outlining structure. And also about reserved URLs, which is not what I wanted to do. Instead use .aspx page as a template file, where I can place my macros(usercontrols) and take advantage of code-behind. But as per your reply that cannot be the case.
I want to thank you very much for your reply.
Cheers!
Ranjit J. Vaity
Am I misunderstanding something here?
If you have usercontrols with codebehind, create a macro for that usercontrol and then you can simply place that macro within a template in umbraco.
Isn't that offering the same functionality?
Peter
Hi Ranjit,
You could write a custom user control and insert that into your template. This can utilise the code-behind coding model.
tht
Jay
I don't get why people are wanting to put functionality into the Page code behind so much, I haven't added functionality into a Page class for a very long time, and even then it's only been something like a property which is just a wrapper for a commonly used piece of code.
Using Page makes it hard to decouple code and decoupling is something that I see to be very important.
But using ASPX as a template goes against the point of introducing the Master Page in .NET 2.0.
I remember using .NET 1.1 and ASPX-as-template which was just a bunch of user controls everywhere.
ASPX doesn't support UI nesting, again another reason why it's not useful as a template.
Hi Slace,
I truly believe that adding .master pages instead others as Umbraco templates should have a very strong reason to support.
Cool, the above post might be the proper reason I was looking out for. This clears my doubt.
Thanks for clarifying this to me.
Peter and Jaygreasley thank you for your contribution.
Cheers,
Ranjit J. Vaity
Hi,
Does anyone know how I can change the master page of a master page in code? I have three umbraco templates (English.Master, German.Master and Page.Master)
In Page.Master, I have set the MasterPageFile to English.Master and that all works great. However, I have a requirement to need to change Page.Master MasterPageFile to German.Master dynamically (either as a result of a property value that the CMS editor enters or something in the query string).
I am aware in .NET that you can change the master page of an aspx page in the PreInit event, but Master pages don't have this, so am stuck.....
Any ideas on how I can acheive this without having a different Page.Master which uses the German.Master (there may be more countries added later and don't want to start the wrong way :-) )
Cheers
Chris
is working on a reply...