Where to put this C# code Options
Mister Wu
Posted: Wednesday, September 19, 2007 8:06:37 PM
Rank: Newbie

Joined: 9/19/2007
Posts: 1
Hi everybody,
If I were coding a normal aspx page, I would have the following C# code:
Code:
protected void Page_PreInit(object sender, EventArgs e)
    {
        //a lot of code and then
        Page.Theme = Theme[i];
    }

Where to put this code in an Umbraco project ?
I don't think it's possible to put it in a master template or am I wrong ?

Thanks for your help.
BarbeRouge
Posted: Thursday, September 20, 2007 12:47:55 PM
Rank: Enthusiast

Joined: 1/8/2007
Posts: 13
As I am not just waiting for a reply, I tried out various methods to get what I want.
Well, the first try was to put the code in a ascx file and insert it as a macro. It doesn't work !
My second try was to follow the method of Peter Gregory, but without results.
My third try was playing around <system.web> section in web config and add theme to the pages section --> Do this and you will get a runtime error ! You will be taught that you should have a <head runat="server"/> tag to do this.
So I added a <?ASPNET_HEAD> tag to my master template. I obtained the same error !
Please help me. I'm very confused.
Eric


Web Design & Traduzioni
drobar
Posted: Thursday, September 20, 2007 2:43:11 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,831
Location: MA, USA
I'm not quite sure where to start... though umbraco is built with .NET, the sites that you create with umbraco rarely need any .NET code. All the things that you're familiar with when creating ASP.NET sites really do not apply. You don't use master pages. Or themes. Or have to play with the web.config. Or build .aspx pages in C#. Or any of that stuff.

Umbraco is not a tool you use to build asp.net websites that somehow gives you content management capabilities.

Umbraco *is* a content management system. It is extensible by using .NET user controls or by altering the source. But, as I said, many sites won't need to do that. Those that do, often need very little.

So, as an ASP.NET guru, you will need to step back and learn the "umbraco way" of doing things. It is both very simple and very powerful. But it is unlike traditional ASP.NET and unlike any other CMS I'm aware of.


I would recommend you read these umbraco books to help you start getting your brain around umbraco.
http://www.umbraco.org/documentation/books/umbraco-basics
http://www.umbraco.org/documentation/books/basics-of-document-types
http://www.umbraco.org/documentation/books/understanding-templates--stylesheets


I would also recommend installing the Website Wizard package, or Warren's Skinnable Website Package. Simply go to the the Developer section of the umbraco UI, right click on Macros, and select "Import Package". Install one of them and then look at how it works, from docTypes to templates to macros to content.


cheers,
doug.

MVP 2007-2009 - Percipient Studios
BarbeRouge
Posted: Thursday, September 20, 2007 3:21:11 PM
Rank: Enthusiast

Joined: 1/8/2007
Posts: 13
Thank to you Doug, It's cool to see there is someone here !
I appreciate your advise, but believe me I already read all the Umbraco's documentation and don't have big problems with templates or xslt (I'm not a guru but I can easily transform the umbraco.xml). I used v 2.1.6 for my skiing association at looking at the excellent job done by Warren with his skinable template.
I didn't see your post before to send a new post - by mistake - at
http://forum.umbraco.org/15481#post-15481
It explains what i want to do and why ! I will post there, so everybody will know the post was related to this thread.


Web Design & Traduzioni
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.