Implement the page for listing all section contents.
We use this page to display all contents of an audio-video section. We have create minimum a skin and the control class to control the skin.
Skin:
\Communities\Common\Themes\Default\Skins\ContentSkins \AudioVideos_AudioVideoSection.ascx
Control class : The "AudioVideoSection" class , which is derived from the "ContentListPage" class, acts as code-behind for this particular skin. (see figure 6). Note that we have initialized the inherited attributes _skinFileName and _getContentItems. From now, the " ContentListPage" class and its ancestor "SkinnedCommunityControle" class will take over most burden jobs such like populating ContentListPage.
ContentList from us. We must only reuse or create custom controls which can be embedded as ItemTemplate in the "ContentList" instance.
- namespace ASPNET.StarterKit.Communities.AudioVideos
- {
- using System;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using ASPNET.StarterKit.Communities;
-
-
-
-
-
-
-
-
-
-
-
-
- public class AudioVideoSection : ContentListPage
- {
- string _skinFileName = "AudioVideos_AudioVideoSection.ascx";
- GetContentItemsDelegate _getContentItems = new GetContentItemsDelegate
- AudioVideoUtility.GetAllAudioVideos);
-
-
-
-
-
-
-
- public AudioVideoSection() : base()
- {
- SkinFileName = _skinFileName;
- GetContentItems = _getContentItems;
- }
- }
- }
Figure 6 (The AudioVideoSection class)
We have created "ItemAVTitle" class to represent the title of an Audio-Video content. It will display the title of a particular content and a image link to represent the type of the content(Audio or Video).
Additionally, we have created an another custom control "AudioVideoEditControl" (figure 7) which is used to navigate to other related pages from section page.
- using System.ComponentModel;
- namespace ASPNET.StarterKit.Communities
- {
- using System;
- [Designer(typeof(ASPNET.StarterKit.Communities.CommunityDesigner))]
- public class AudioVideoEditContent : EditContent
- {
-
-
-
-
- public AudioVideoEditContent()
- {
- if (Context != null)
- {
- PageInfo _pageInfo = (PageInfo)Context.Items["PageInfo"];
- int contentPageID = _pageInfo.ID;
- AddUrl = "AudioVideos_AddAudioVideo.aspx";
- EditUrl = String.Format("AudioVideos_EditAudioVideo.aspx?id={0}", contentPageID);
- DeleteUrl = String.Format("ContentPages_DeleteContentPage.aspx?id={0}", contentPageID);
- MoveUrl = String.Format("ContentPages_MoveContentPage.aspx?id={0}",
- ontentPageID);
- CommentUrl = String.Format("Comments_AddComment.aspx?id={0}", contentPageID);
- ModerateUrl = "Moderation_ModerateSection.aspx";
- }
- }
- }
- }
Figure 7
Finally , we must register this page as section page using the following the statement
- /* registers AudioVideoSection as section PageType*/
- IF NOT EXISTS (SELECT * FROM Community_PageTypes WHERE pageType_Name='AudioVideoSection')
- BEGIN
- INSERT INTO Community_PageTypes
- (
- pageType_Name,
- pageType_Description,
- pageType_PageContent,
- pageType_isSectionType
- )
- VALUES
- (
- 'AudioVideoSection',
- 'Contains AudioVideo listings',
- 'ASPNET.StarterKit.Communities.AudioVideos.AudioVideoSection',
- 1
- )
- END
- Go
continue article