Creating User Controls Options
ascendinternet
Posted: Tuesday, January 01, 2008 7:55:15 PM

Rank: Aficionado

Joined: 11/16/2007
Posts: 156
Location: Surrey, UK
I probably should really know the answers to these questions, but I think I need confirmation!

I would like to create some UserControls for an Umbraco site I am working on. I have Visual Studio 2005 Professional.

1. what type of project should I use in Visual Studio?
2. does the code have to be compiled into a dll or can it be part of the ascx?
3. how do I (can I?) access Umbraco functions (e.g. NiceUrl)


Sorry if these questions are a bit dumb! :blush:

Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
simm2
Posted: Tuesday, January 01, 2008 11:20:41 PM
Rank: Enthusiast

Joined: 12/22/2007
Posts: 12
Hi Gordon!

As a response to your questions

1. Class Library
2. You can actually do both and also with a separate code behind-file. I usually develop without compiling into DLL, because it is faster than having to press build each time. Then, when I need to distribute the file to a client I compile it into a DLL for easy distribution. If you choose not to compile every time, the .aspx.cs file must reside in the same location as the aspx-file
3. You do that by referencing the umbraco.dll file. Once done, you'll see Library pop up in the Intellisense box

Hope this helps

Simon
ascendinternet
Posted: Tuesday, January 01, 2008 11:59:10 PM

Rank: Aficionado

Joined: 11/16/2007
Posts: 156
Location: Surrey, UK
Thanks for the reply Simon! I created a "ASP.NET Web Application" as it seemed to be the easiest one to create ascx files in. I'll try a "Class Library" later :)

I did eventually remember that I needed to create a reference to the Umbraco dll - that bit works fine now.

I assume it's no problem to access the web.config file from a User Control? I'd like to pick up the mail server setting.

Gordon Saxby | Ascend Internet Limited | Web Site Development. Web Site Hosting (inc Umbraco)
simm2
Posted: Wednesday, January 02, 2008 1:54:03 AM
Rank: Enthusiast

Joined: 12/22/2007
Posts: 12
Hi Gordon

Oh, yes - my mistake - you can ofcourse use Web Application project if you want a project template to work with :-)

In order to retrieve web.config-settings you can use:
System.Configuration.ConfigurationSettings.AppSettings["umbracoSmtpServer"]

Hope this helps
Simon
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.