namespace ASPNET.StarterKit.Communities { using System; using System.Web.UI; using System.Web.UI.WebControls; using System.Web; using ASPNET.StarterKit.Communities; //********************************************************************* // // CustomModule Class // // Displays a user control (.ascx file) in the content area of // a community page. // //********************************************************************* [ParseChildren(true)] public class CustomModule : WebControl, INamingContainer { //********************************************************************* // // CreateChildControls Method // // Loads user control into Controls collection. The user control // must be located at the following path: // // ~/Communities/[communityName]/CustomModules/[sectionName].ascx // //********************************************************************* protected override void CreateChildControls() { string skinFileName; Control skin; // Determine skin file name CommunityInfo objCommunityInfo = (CommunityInfo)HttpContext.Current.Items[ "CommunityInfo" ]; SectionInfo objSectionInfo = (SectionInfo)HttpContext.Current.Items[ "SectionInfo" ]; skinFileName = String.Format( "{0}/Communities/{1}/CustomModules/{2}.ascx", CommunityGlobals.AppPath, objCommunityInfo.Name, objSectionInfo.Name ); try { //Chargement du UserControl*********** skin = Page.LoadControl(skinFileName); //************************************ Controls.Add(skin); } // Catch errors so they can be displayed. catch (HttpException he) { Controls.Add(new LiteralControl(he.GetHtmlErrorMessage())); Context.Trace.Warn( "community error","HttpException ::",he); } catch (System.IO.FileNotFoundException fnf) { string errorMessage = fnf.Message+" Not Found"; Controls.Add( new LiteralControl(errorMessage) ); Context.Trace.Warn("community error",errorMessage,fnf); } // guess that the file was not found? catch (Exception e) { string errorMessage = "An unknown exception caused static page ("+skinFileName+") load abort -- see trace file for more info"; Controls.Add( new LiteralControl( errorMessage ) ); Context.Trace.Warn( "community error", errorMessage, e); } } } }
if(!IsPostBack) { SqlDataAdapter dadGet = new SqlDataAdapter( "Community_AdminGetUsersForLetter", CommunityGlobals.ConnectionString); dadGet.SelectCommand.CommandType = CommandType.StoredProcedure; dadGet.SelectCommand.Parameters.Add("@communityID", CommunityGlobals.CommunityID); dadGet.SelectCommand.Parameters.Add("@letter", ""); dadGet.SelectCommand.Parameters.Add("@sortBy", "0"); dadGet.SelectCommand.Parameters.Add("@orderBy", "0"); DataSet dstUsers = new DataSet(); dadGet.Fill(dstUsers); DataGrid1.DataSource = dstUsers; DataGrid1.DataBind(); }
<%@ Control Language="c#"%> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="ASPNET.StarterKit.Communities" %> <script runat="server"> void Page_Load() { //Code ... } </script> <asp:DataGrid id="DataGrid1" runat="server" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical"> <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle> <AlternatingItemStyle BackColor="#DCDCDC"></AlternatingItemStyle> <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle> <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle> <PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle> </asp:DataGrid>
namespace ASPNET.StarterKit.Communities { using System; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; /// <summary> /// Summary description for Membres. /// </summary> public class Membres : System.Web.UI.UserControl { protected System.Web.UI.WebControls.DataGrid DataGrid1; private void Page_Load(object sender, System.EventArgs e) { // Code .... } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }
namespace ASPNET.StarterKit.Communities { ...
<%@ Control Language="c#" AutoEventWireup="false" Codebehind="Membres.ascx.cs" Inherits="ASPNET.StarterKit.Communities.Membres" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%> <asp:DataGrid id="DataGrid1" runat="server" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" BackColor="White" CellPadding="3" GridLines="Vertical"> <FooterStyle ForeColor="Black" BackColor="#CCCCCC"></FooterStyle> <SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#008A8C"></SelectedItemStyle> <AlternatingItemStyle BackColor="#DCDCDC"></AlternatingItemStyle> <ItemStyle ForeColor="Black" BackColor="#EEEEEE"></ItemStyle> <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084"></HeaderStyle> <PagerStyle HorizontalAlign="Center" ForeColor="Black" BackColor="#999999" Mode="NumericPages"></PagerStyle> </asp:DataGrid>
CREATE PROCEDURE Community_EventsGetCurrentEvents @communityID int -- @username NVarchar(50) AS DECLARE @currentDate DateTime SET @currentDate = GetUtcDate() DECLARE @currentMonth int SET @currentMonth = DATEPART(month, @currentDate) DECLARE @pageType int SET @pageType = dbo.Community_GetPageTypeFromName('Event') DECLARE @PageIndex TABLE ( PageID int ) INSERT INTO @PageIndex(PageID) Select ContentPage_ID FROM Community_ContentPages WHERE ContentPage_CommunityID = @communityID AND ContentPage_PageType = @pageType AND ContentPage_ModerationStatus = 1 AND ContentPage_DateVisible < @currentDate AND ContentPage_SortOrder >= @currentDate AND DATEPART(month, ContentPage_SortOrder) BETWEEN @currentMonth and @currentmonth + 1 SELECT null Event_Link, null Event_FullDescription, Event_Location, Event_Speaker, Image_ID, Image_FileName, null, Event_SpeakerBiography, null Image_FileName, Content.* FROM dbo.Community_GetContentItem(@communityID, NULL, @currentDate) Content INNER join Community_Events With(nolock) ON ContentPage_ID = Event_ContentPageID INNER JOIN @PageIndex PI ON ContentPage_ID = PI.PageID LEFT OUTER JOIN Community_SectionImages (nolock) ON ContentPage_ID = Image_ContentPageID ORDER BY ContentPage_SortOrder RETURN GO
<%@ import Namespace="ASPNET.StarterKit.Communities" %> <%@ Register TagPrefix="community" Namespace="ASPNET.StarterKit.Communities" Assembly="ASPNET.StarterKit.Communities" %> <%@ Control Language="c#" AutoEventWireup="false" Codebehind="WebBoxCurrentEvent.ascx.cs" Inherits="ASPNET.StarterKit.Communities.WebBoxCurrentEvent" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> <%@ Outputcache duration="600" VaryByControl="Title"%> <span class="webBox_TitleText" id="Title" runat="server"></span> <br> <community:ContentList id="ContentList" Runat="Server"> <ItemTemplate> <li> <community:ItemTitleLink Runat="Server" /> <br> <span class="WebBox_Content"> Le <community:ItemEventDate Runat="Server" /><br> <community:ItemBriefDescription Runat="Server" /> </span> <br> <br> </ItemTemplate> </community:ContentList>
namespace ASPNET.StarterKit.Communities { using System; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Collections; /// <summary> /// Summary description for WebBoxCurrentEvent. /// </summary> public class WebBoxCurrentEvent : System.Web.UI.UserControl { protected System.Web.UI.HtmlControls.HtmlGenericControl Title; protected ASPNET.StarterKit.Communities.ContentList ContentList; private ArrayList events = new ArrayList(); private void Page_Load(object sender, System.EventArgs e) { //Appel de la procstok if (!Page.IsPostBack) { SqlConnection conn = new SqlConnection(CommunityGlobals.ConnectionString); SqlCommand comm = new SqlCommand("Community_EventsGetCurrentEvents", conn); comm.CommandType = CommandType.StoredProcedure; comm.Parameters.Add("@communityID", CommunityGlobals.CommunityID); conn.Open(); SqlDataReader dr = comm.ExecuteReader(); while(dr.Read()) { events.Add(new Events.EventInfo(dr)); } conn.Close(); Title.InnerHtml = "Prochain vnements"; ContentList.DataSource = events; ContentList.DataBind(); } } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion } }