.NET USER CONTROLS

.NET user controls provide an endless number of possibilities for your Umbraco installation. With user controls you can harness the power of .NET code inside your templates and content pages. If you can create something in a custom .NET application inside a user control, it's also possible to render/function it in an Umbraco rendered page.

image Remember to have a <form runat=“server”/> tag in your template that encapsulates the user control. If you don't, the user control will not work.

This section shows how to extend the user experience by adding dynamic form functionality, as well as how to create custom data types for user input in the backoffice.

image For detailed information on how to tap into the Umbraco Event Model, go to Chapter 12.

Using the built-in wrapper makes deploying custom code a real breeze. The simplest and most straightforward way to work with Umbraco and custom code is to create a standalone Visual Studio project in—basically—6 steps.

  1. Add your user controls (.ascx files).
  2. Write the code as needed.
  3. Build your solution and/or project.
  4. Copy the .ascx file(s) to the <install root>/usercontrols folder and copy the project DLL and any other dependency libraries used to the <install root>/bin folder.
  5. Create a macro, just like you did in the “Introduction to Umbraco Macros” section in the beginning of this chapter, and browse to the required user control in the dropdown.
  6. Add the macro to your template or page, and that's it!

image If you don't see your newly created user control in the edit macro details view, simply touch the web.config file in your installation and the application will restart manually. Touching the web.config means that you make a change to the file by adding a space and saving the file to update its last updated timestamp. This should clear any potential caching and you should see the file(s) listed.

If you do not have direct access to the root of your Umbraco website, installing the Config Tree package, found at http://our.umbraco.org/projects/developer-tools/config-tree, allows you edit access to the web.config and other configuration files in your Umbraco installation.

To make the backoffice as flexible as possible, Umbraco introduced the UserControlWrapper, which allows you to develop various input fields and add them as data types in the Developer section. See Chapter 12 for further information and examples on this topic.

In addition to allowing you to do everything in XSLT, .NET user controls provide you with methods for working with unpublished content.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.103.5