I'm want to make some usercontrols for mu Umbraco site. I downloaded the source code version and fired it up in VS2008, but it does not run the installer, so I don't get the database content created.
Do I need to do something specific ?
- or do you use a different approach to develop umbraco usercontrols ?
Here's what I usually do when developing for an umbraco site:
Download either an official release (v4.0.0/v4.0.1) or the latest changeset.
If downloading an official release, just go and install that one according to the documentation which can be found on http://umbraco.org/documentation/books (Look for the install section)
If using a changeset, open up the solution for the version you'd like to use. Build the complete solution. If solution build, copy the complete content of presentation folder into the folder for the umbraco installation. From there on, follow the tutorial on installing umbraco.
For own development of user controls, fire up vs.net again and create a new web project. Add the relevant user controls and start coding and building. Add a post build event that will copy:
- Dll's to the /bin folder of the umbraco installation
- user controls to the /usercontrols folder of the umb installation
From there on, use macro's, templates and the like to get the user controls in your umbraco site.
Great thing about this setup is you get to debug user controls or umbraco quite easily. Just attach a debugger to the asp_net worker process (w3wp.exe in vista) and start debugging whenever something's not working as expected.
1) code in your own web project,
2) copy the the release installation of Umbraco
3) Run - and debug there.
4) go back to your own project again and make changes and correct errors and go back to 2) again
I would like to access umbraco business logic in my own project. I'm trying to make a calendar control so I need to access event nodes created.
I supposed I have to copy some of the umbraco dll's to my bin folder and make my connection string point to my umbraco database.
For dll references, I usually reference dll's from the /bin folder of the umbraco install.
Don't have to create new connection strings, as all this info becomes available if you reference the correct dll's.
If you wish to work with umbraco documents, there's no need to create/change a connection string. Even if you're using custom tables alongside the umbraco standard tables.
For example, next code snippet adds a record to a custom table:
What Dirk means with umb installation is the folder where you've installed Umbraco in. Regarding the .cs file you have two options 1 make it a dll and store the dll in the /bin folder or just put the .cs file along with you usercontrol. I prefer the first option.
How do you register it as a macro then when theres no ascx file ?
I tried registering it as a Custom control but gets nothing displayed on my page - it does not sound correct either.
[quote]How do you register it as a macro then when theres no ascx file ?[/quote]
You don't! Macro's are supposed to work with either xslt files or ascx files (user controls).
If you have built a custom control, you'll have to wrap it in a user control!
Hi Dirk
Thanks for trying to help.
I just have to have this cleared out. I have a usercontrol which I compile into a dll. I registrered it as a custom control - which I believe is wrong. I added it to a page and started up my umbraco site. I then attached my debugger to the aspnet_wp process and I see my code being executed - I can step through it. I just don't see the controls displayed on my page - I do however see the output of a Resonse.Write.
Is it because my approach with the usercontrol compiled into a dll does not work for umbraco ?
- or is it because I'm not registrering it correct
Don't see what it's meant by registering it as a custom control? Just need to have the user control copied to the usercontrols dir, dll goes into bin folder and create a new macro that references the user control. Nothing else is required? If you can attach/debug and step through using vs.net, then the user control gets hit, just not sure why it doesn't display! Don't know at this point what the user control is supposed to do of course! Any hints on that?
Hi
By registrering I mean creating a new macro and because my usercontrol is compiled into one dll - the ascx file too - I see my only option is to use the Custom conrol option.
I think the idea about compiling it all into one dll is not to exposed the ascx file - that's why in this case I don't have an ascx file.
I sounds as if I can't used the 'Compile the usecontrol into a dll' option
Ascx file (user control) has to go to the user control directory. Assembly into /bin directory.
If ascx file has not been copied to the /usercontrols dir, no macro referencing that user control can be created.
Developing using VS2008
Hi
I'm want to make some usercontrols for mu Umbraco site. I downloaded the source code version and fired it up in VS2008, but it does not run the installer, so I don't get the database content created.
Do I need to do something specific ?
- or do you use a different approach to develop umbraco usercontrols ?
Thanks
Paul S
Hi,
Here's what I usually do when developing for an umbraco site:
Download either an official release (v4.0.0/v4.0.1) or the latest changeset.
If downloading an official release, just go and install that one according to the documentation which can be found on http://umbraco.org/documentation/books (Look for the install section)
If using a changeset, open up the solution for the version you'd like to use. Build the complete solution. If solution build, copy the complete content of presentation folder into the folder for the umbraco installation. From there on, follow the tutorial on installing umbraco.
For own development of user controls, fire up vs.net again and create a new web project. Add the relevant user controls and start coding and building. Add a post build event that will copy:
- Dll's to the /bin folder of the umbraco installation
- user controls to the /usercontrols folder of the umb installation
From there on, use macro's, templates and the like to get the user controls in your umbraco site.
Great thing about this setup is you get to debug user controls or umbraco quite easily. Just attach a debugger to the asp_net worker process (w3wp.exe in vista) and start debugging whenever something's not working as expected.
Good luck,
Regards,
/Dirk
Thanks Dirk.
It sounds as if it's
1) code in your own web project,
2) copy the the release installation of Umbraco
3) Run - and debug there.
4) go back to your own project again and make changes and correct errors and go back to 2) again
I would like to access umbraco business logic in my own project. I'm trying to make a calendar control so I need to access event nodes created.
I supposed I have to copy some of the umbraco dll's to my bin folder and make my connection string point to my umbraco database.
Paul S
Yup,
For dll references, I usually reference dll's from the /bin folder of the umbraco install.
Don't have to create new connection strings, as all this info becomes available if you reference the correct dll's.
If you wish to work with umbraco documents, there's no need to create/change a connection string. Even if you're using custom tables alongside the umbraco standard tables.
For example, next code snippet adds a record to a custom table:
[code]ISqlHelper helper = DataLayerHelper.CreateSqlHelper(GlobalSettings.DbDSN);
helper.ExecuteNonQuery("INSERT INTO TABLE(Id) VALUES (@Id)",
helper.CreateParameter("@Id", 1));[/code]
Hope this helps.
Regards,
/Dirk
Copy the dll's to the bin folder - ok
- user controls to the /usercontrols folder of the umb installation - ?
Whats the umb installation in this case ?
The ascx file in my project refers to the cs file. The make it refer to the dll I normally do a 'Publish website'
Regards
Paul S
Hi,
What Dirk means with umb installation is the folder where you've installed Umbraco in. Regarding the .cs file you have two options 1 make it a dll and store the dll in the /bin folder or just put the .cs file along with you usercontrol. I prefer the first option.
Hope it helps you,
Cheers,
Richard
Hi
How do you register it as a macro then when theres no ascx file ?
I tried registering it as a Custom control but gets nothing displayed on my page - it does not sound correct either.
Regards Paul S
Hi,
[quote]How do you register it as a macro then when theres no ascx file ?[/quote]
You don't! Macro's are supposed to work with either xslt files or ascx files (user controls).
If you have built a custom control, you'll have to wrap it in a user control!
Hope this helps.
Regards,
/Dirk
Hi Dirk
Thanks for trying to help.
I just have to have this cleared out. I have a usercontrol which I compile into a dll. I registrered it as a custom control - which I believe is wrong. I added it to a page and started up my umbraco site. I then attached my debugger to the aspnet_wp process and I see my code being executed - I can step through it. I just don't see the controls displayed on my page - I do however see the output of a Resonse.Write.
Is it because my approach with the usercontrol compiled into a dll does not work for umbraco ?
- or is it because I'm not registrering it correct
Thanks
Paul S
Hi,
Don't see what it's meant by registering it as a custom control? Just need to have the user control copied to the usercontrols dir, dll goes into bin folder and create a new macro that references the user control. Nothing else is required? If you can attach/debug and step through using vs.net, then the user control gets hit, just not sure why it doesn't display! Don't know at this point what the user control is supposed to do of course! Any hints on that?
Regards,
/Dirk
Hi
By registrering I mean creating a new macro and because my usercontrol is compiled into one dll - the ascx file too - I see my only option is to use the Custom conrol option.
I think the idea about compiling it all into one dll is not to exposed the ascx file - that's why in this case I don't have an ascx file.
I sounds as if I can't used the 'Compile the usecontrol into a dll' option
Regards
Paul S
Hi,
Ascx file (user control) has to go to the user control directory. Assembly into /bin directory.
If ascx file has not been copied to the /usercontrols dir, no macro referencing that user control can be created.
Regards,
/Dirk
Thanks Dirk
That's also what I ended up realizing - thanks for clarifying.
Regards
Paul S
is working on a reply...