Help with usercontrols/behind files. Best practices?
just go to tl:dr if you dont want to read the wall of text
Ok i know the title makes this sound like a question thats been asked a billion times, but i couldnt find anything that answered my doubts. (Though if it exist i might just be blind) but hear me out.
The thing is, ive been working for a while at company that already had a couple of umbraco sites up and running and ive just been coding with xslt and the templates, nothing major.
But now i am tasked with a more "ordinary" coding task that requires more than just xslt. "Create user", a familiar use case. There is already one in place, but its an .asp file shown in an iframe (a remnaft of the previous website that wasnt remade in umbraco due to time constraints)
The thing is, in this case its quite a heavy process of information that needs to be saved to a database with lots of data and sql, and more.
So in this case it's obvious i need some sort of user control or behind file. Or something else. That is why i am asking here because perhaps someone could enlighten me on what is the best way of dealing with this.
tl:dr
If you were tasked with the assignment of making a "create user" use case in an already existing umbraco site, how would you do it? (you are required to write sql).
I would make the create user code as a user control. You can then embed that control into your templates. If you need to pass in variables from the the Umbraco page that it's embedded on (such as page name, or ID for example), then you can make it into a user control macro, and embed the macro into the page instead.
I'd create a web project for the user controls, and then compile it and add the dll to the site bin folder and the user control to the usercontrols folder.
My normal setup is a Visual Studio solutions with a web project contaning the Umbraco site, and then a web project for any extensions/user controls that I need to write. I may sometimes have additional projects for things like datalayers etc. My web project for the extensions has build events assigned to it so that the relevant files are copied back to the Umbraco site on build.
Thank you for your replies, i would mark both as solutions if i could. I think i managed to get it up and running, need to test it some more to be fully sure, but non the less, i am definetly on the right track.
Help with usercontrols/behind files. Best practices?
just go to tl:dr if you dont want to read the wall of text
Ok i know the title makes this sound like a question thats been asked a billion times, but i couldnt find anything that answered my doubts. (Though if it exist i might just be blind) but hear me out.
The thing is, ive been working for a while at company that already had a couple of umbraco sites up and running and ive just been coding with xslt and the templates, nothing major.
But now i am tasked with a more "ordinary" coding task that requires more than just xslt. "Create user", a familiar use case. There is already one in place, but its an .asp file shown in an iframe (a remnaft of the previous website that wasnt remade in umbraco due to time constraints)
The thing is, in this case its quite a heavy process of information that needs to be saved to a database with lots of data and sql, and more.
So in this case it's obvious i need some sort of user control or behind file. Or something else. That is why i am asking here because perhaps someone could enlighten me on what is the best way of dealing with this.
tl:dr
If you were tasked with the assignment of making a "create user" use case in an already existing umbraco site, how would you do it? (you are required to write sql).
For a start you can watch this free video on how to create a usercontrol: http://umbraco.com/help-and-support/video-tutorials/introduction-to-umbraco/developer-introduction/using-net-user-controls/TVPlayer
Do you want to create a user (who can login into Umbraco) or a member (who can login in the frontend website)?
For a user it's best to look at the source of Umbraco. For example the MakeNew method in here: http://umbraco.codeplex.com/SourceControl/changeset/view/751c9aa11bbd#umbraco%2fbusinesslogic%2fUser.cs
For a member this topic might help: http://our.umbraco.org/forum/developers/extending-umbraco/27616-Enable-members-to-edit-their-profile-data or you can also look at the source for the MakeNew method in here: http://umbraco.codeplex.com/SourceControl/changeset/view/751c9aa11bbd#umbraco%2fcms%2fbusinesslogic%2fmember%2fMember.cs
Jeroen
I would make the create user code as a user control. You can then embed that control into your templates. If you need to pass in variables from the the Umbraco page that it's embedded on (such as page name, or ID for example), then you can make it into a user control macro, and embed the macro into the page instead.
I'd create a web project for the user controls, and then compile it and add the dll to the site bin folder and the user control to the usercontrols folder.
My normal setup is a Visual Studio solutions with a web project contaning the Umbraco site, and then a web project for any extensions/user controls that I need to write. I may sometimes have additional projects for things like datalayers etc. My web project for the extensions has build events assigned to it so that the relevant files are copied back to the Umbraco site on build.
Hope that helps!
:)
Thank you for your replies, i would mark both as solutions if i could. I think i managed to get it up and running, need to test it some more to be fully sure, but non the less, i am definetly on the right track.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.