This sample demonstrates how to implement an Intra-Site module using provider pattern (the same pattern we use for our pluggable modules). The benefit of implementing an
Intra-Site module in this manner is that you will create a rather robust and flexible module, while on the other hand the implementation of the user interface will be much
simpler, because you will do it with User Controls.
For data access, LINQ to SQL provider has been used.
What is Supplied in This Sample?
In the App_Code folder you will find the Contacts folder which contains the code for Contacts module:
-
Configuration folder – contains classes for contacts module section in web.config and provider declaration
- ConfigHelper.cs - helper class which gets you <telerik> .. <contacts> section from the web.config file
- SectionHandler.cs – class which handles the <telerik> .. <contacts> section from the web.config file
-
Interfaces folder – contains interfaces of an object we will be using in Contacts module
- IContact.cs – interface describing contact object
- IDepartment.cs – interface describing department object
-
LINQData folder – folder containing Contacts.dbml file and classes extending LINQ objects
- Contacts.dbml – class representing the contacts module database tables as LINQ objects
- Contact.cs – class extending Contact LINQ object
- Department.cs – class extending Department LINQ object
-
Providers folder – contains Contacts provider base class and LINQ to SQL provider implementation
- BaseContactsProvider.cs – base abstract class which must be implemented by any Contacts provider
- LinqContactsProvider.cs – LINQ to SQL Contacts provider implementation (this class inherits BaseContactsProvider)
- ContactsManager.cs – Contacts module API class
- ContactsModule.cs – main module class for Contacts module
- IContactsControlPanel.cs – interface that defines the required members of Contacts module Control Panel
In the App_Data folder you will find Sitefinity.mdf database, used to build this sample.
In the ContactsModule folder you will find the user interface elements of Contacts module:
-
Admin folder – user controls for the admin side of the module
- ControlPanel.ascx and ControlPanel.ascx.cs – user control representing Control panel
- CommandPanel.ascx and CommandPanel.ascx.cs – user control representing Command panel
-
Scripts folder – external java script files used by the module
- CommandPanel.js – implements certain client-side functionalities of Departmens treeview
- ContactsList.ascx and ContactsList.ascx.cs – represents public control for displaying list of controls
- SingleContact.ascx and SingleContact.ascx.cs – represents public control for displaying single contact
Finally, you will find the web.config file with the declaration and implementation of <telerik> .. <contacts> section.
How to Install This Sample?
- Create a new Sitefinity Web site.
- Download the sample code from here.
- Copy the App_Code folder from the sample to your Web site.
- Copy the Sitefinity.mdf database from App_Data folder from the sample to the App_Data folder in your Web site.
- Copy the ContactsModule folder from the sample to your folder.
- Register the <telerik> .. <contacts> section in your web.config file. It should look like this:
| web.config |
Copy Code |
|
<sectionGroup name="telerik">
…
<section name="contacts" type= "Samples.Contacts.Configuration.SectionHandler" requirePermission="false" />
… </sectionGroup>
|
- Register the Contacts module with Sitefinity. It should look like this:
| web.confi |
Copy Code |
|
<modules>
…
<add type="Sample.Contacts.ContactsModule"/>
… </modules>
|
- Declare the <telerik> .. <contacts> section. It should look like this:
| Example Title |
Copy Code |
|
<telerik>
…
<contacts defaultProvider="Sitefinity">
<providers>
<clear/>
<add name="Sitefinity" type="Samples.Contacts.Providers.LinqContactsProvider" visible="true"/>
</providers>
</contacts>
</telerik>
|
- Run the Web site.
See Also