By Ruben Gatt
October 2010
In this tutorial we provide a step by step guide on how to work with Lists in DNM Rad.
One feature in DNM Rad that is often overlooked is Lists.
Lists gives the user the ability to set pre-defined lists of data and use it in a DNM Rad application without going through the hassle of creating the table and forms to input the list data.
In this example we are going to utilize the DNM Contact Form which is available for free from
snowcovered.
For this example we will ask the user:
- Is this the first visit to our website?
- Do you own any of our products?
- Which country do you currently reside?
Now at first glance you may notice that the first two questions require a Yes or No answer, for this we will use the Lists functionality. For the other question we will make use of the predefined lists availble in DNM Rad.
So we are going to assume that you have the Contact Form unpackaged and deployed in your website.
So first we will access the DNM Rad Control Panel, as you can see the fifth option is ‘Lists’, click on Lists to access the lists screen.
The lists screen consits of three sections, the list parent (1), list information (2) and list preview (3).
1. List Parent – This is where you can setup the parent list, this means that a list can have many child lists. It is also built like this so you can identify the list you are going to use without limiting the user to have only one level per list.
So for example you can have the following List:
- Clothes
- Trousers
- Shirts
- Long Sleeved
- Short Sleeved
2. List Information – This section is where you define your list item (which can be used as a list parent as well). So to use the same list example, first we need to input the parent list ‘Clothes’. So we make sure that from List Parent we select ‘-Root-‘, and then type the list name (Clothes) and the list value (Clothes), view Rights can be left ‘All Users’. Click Save to save the list, which now can be used as a parent for Trousers and Shirts by selecting it the List Parent dropdown.
View Rights can be used to limit a list entry so for example ‘Short Sleeved’ to be available for a particular User Role only.
3. List Preview – This is where the list item under the selected List Parent is displayed.
With the list screen explained we will go into creating the lists required for our contact form. We need to create a parent list which we will name ‘YesorNo’, the screenshot below gives you exactly how this should be created.
Now we need to create the list items for the list ‘YesorNo’, we do this by selecting ‘YesorNo’ from the list parent dropdown. Then add the two list items Yes and No, note that the list value is what will be saved if you save the information gathered from the form. Even if you send the information via email the list value will be sent in the email, so make sure to use a list value that fits the purpose of the form.
Since this is a contact form we will use a readable list value. Follow the screenshots below to add the two list items.
We have successfully created our list, now we need to deploy the control in our contact form to use the list we just created. Go back to the control panel and click on Forms; click on ‘ContactForm’ to access the contact form template.
Go into templates and in the Body Template add the following code.
We will use a dropdown to list the countries and two radio button lists to display our ‘YesorNo’ pre-defined list. Now click on properties to set up our new controls to work as planned.
First lets modify the properties of the control ‘drpCountry’, the only property we need to modify is the property ‘Drop Down Type’, change this to the type ‘Countries’. This means that the dropdown will be populated from the list of countries available with DNN. (There are more pre-defined lists that can be used e.g. States, Users, etc..)
Next we need to set the properties of the second control called ‘rdVisitWebsite’. Click on the control to load the control properties.
Here we need to modify two properties, first we need to modify the List Type and set this to ‘Lists’ then we need to select the list we want to load. We shall be using the list ‘YesorNo’ as shown in the screenshot below. Do the same for the control ‘rdProducts’.
After saving, view the contact form and as you can see in the screenshot below, we have our new control populated from lists.
As you can see the process of binding these controls to these lists was very easy and efficient. Lists give you the possibility to set a pre-defined list that can be used in more than one place, without going through the effort of setting up a table and filling the table with data.
The last thing that you need to do to complete this application is to add these three new controls to the email template (Form Name: EmailTemplate) so that the data selected in the contact form will be sent via email. Use the screenshot below as a reference on how you can achieve this.
If you have any problems working with the DNM RAD module you can visit the
DotNetMushroom Forums DotNetMushroom will exhibit at the OpenForce Europe 2010 We are pleased to announce that once again, we will be present at the OpenForce Europe 2010, which is going to be held between the
25th and 26th October in Zeist, Netherlands. In fact we are also Silver Sponsors. You can come over and visit us at our exhibition booth on both days of the conference. Myself and Mr. Justin Mifsud will be there. We head the Development and Design/UI divisions (respectively) at DotNetMushroom and both form part of the DotNetMushroom RAD core team. We would obviously be more than happy to answer any of your queries.
Comments