Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dan 3 posts 23 karma points
    Jul 05, 2013 @ 06:00
    Dan
    0

    Asp.Net User Controls N-Tier

    Hi:I have found a couple of posts asking about this topic, but none of the responses seem to address my question. I have many user controls that are part of a multi layer solution: Data layer that talks to MS Sql Server, Repository that talks to data layer, Business Logic Lyer that talks to Repository Layer and user controls which talk to Business Logic Layer. How do I use these user controls in Umbraco? The only video tutorial I can find is from 2008 and shows very basic examples (e.g. Hello World). How do you use user controls that rely on mutlplie layers that are each contained in separate projects within a solution? Is there any detailed documentation / tutorials on how to do this?Also, since I am evaluating Umbraco vs Sitefinity: With Sitefinity I am able to it up as a separate project within my overall Visual Studio 2012 solution which makes it much easier to have Sitefinity import my user controls because everything is withing the same solution. Can I do the same using Umbraco? Said another way, is there a way to simply set up Umbraco as its own project in a Visual Studio Solution, and then create references to user controls that are contained in other projects within that same solution. That would ceratinly make Umbraco more attractive to me. ?Or is the only way to work with Umbraco to do your Umbraco work in WebMatrix, your user control development in Visual Studio and then keep copying everything over from VS to WebMatrix (which seems very cumersome to me for large projects that have a lot of user controls)?Finally, there seems to be a lot more tutorials about how to use razor rather than User Controls. Is this an indication that Umbraco no longer has an emphasis on Webform user controls in favor of the newer Razor / MVC direction?Thanks, Dan

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jul 05, 2013 @ 22:22
    Andy Butland
    0

    Hi Dan

    You certainly can have your user controls in a seperate project, but you will need to ensure your compiled dll to the bin folder of your Umbraco project, and also your ascx file is copied over to the Umbraco usercontrols folder.

    You can use a post-build script to XCOPY them over on your "controls" project,  Something like:

    xcopy "$(ProjectDir)usercontrols\*.ascx" "C:\MyProject\usercontrols\" /y

    You can have your Umbraco project in VS.Net too though, no need to jump between that and WebMatrix.

    Hope that helps

    Andy

  • Dan 3 posts 23 karma points
    Jul 05, 2013 @ 22:50
    Dan
    0

    Hi Andy:

    Thank you for the response. So, I am still unclear about the n-tier part of my question. This may be because I am not that skilled in understanding DLLs. In my setup I have five different projects as previosly described. Does the DLL you are telling me to XCopy include all of the projects - thus even though I have all of these different project / layers - by copying over the DLL I will get all of the connected code from the layers for use by Umbraco and my user controls will execute as they do now (e.g.like they do as part of a webform in my test environment)?

    And, as far as using Umbraco inside of my VS 2012 solution, do I just set that up as a sixth project in my solution? Are there any special setup requirements for using Umbraco inside of a VS 2012 solution or does it just set up automatically when you use Nuget? I did try and set up a simple project in VS 2012, but got errors right away because it did not a like a line of code Script.Render in a site.master page ... I was surprised I got errors right out of the box and that is why I thought I had to use WebMatrix.

    Thanks, Dan

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jul 06, 2013 @ 14:02
    Andy Butland
    0

    I'm away at the moment Dan but will give it a try later to make sure I remember the exact steps and post back... if no-one else chips in first.

    From memory though if you create a sixth project as you say as an empty web application project, pull in Umbraco via NuGet and then add references to the necessary other projects - I think that will handle the necessary dlls.  The XCOPY method would be needed for the .ascx files.

    Andy

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Jul 07, 2013 @ 21:16
    Andy Butland
    0

    Hi Dan

    As mentioned have tried it out to make sure my memory is right... these are the steps I used which should help you to set things up.

    Create a solution with 3 projects:
    - Project A (class library - simulating one of your upper layers like business logic)
    - Project B (empty web application - for your user controls)
    - Project C (empty web application - for Umbraco - set this as your startup project)

    Set references so C references B and B references A.

    In project B create a user control that uses a method in project A (I presume you will have this already in your existing app)

    In project C install UmbracoCms from NuGet.  Rebuild the solution.

    Run the solution and go through the installer to set up Umbraco.

    Under the Developer section, create a macro and save it.

    Add this post-buid script in project B (you'll need to amend the paths to fit your projects):

    xcopy "$(ProjectDir)*.ascx" "$(SolutionDir)\WebUI\usercontrols\" /y 

    Rebuild solution.

    Go back into your macro - you should now be able to select from your user controls.

    Create a document type and template that uses the macro.  Create a piece of content and view it.  You should see your user control working and displaying the information you'd expect from calling up to your other tiers.

    Hope that helps.

    Andy

     

     

     

     

     

     

  • Dan 3 posts 23 karma points
    Jul 08, 2013 @ 17:50
    Dan
    0

    Andy:

    Thank you very much for the second follow up. I will work on implementing based on your suggestions. Thanks again...Dan

Please Sign in or register to post replies

Write your reply to:

Draft