Attaching elements
Step 13 – Examples of MyUrlAction.aspx and MyUrlAction.aspx.cs
The following are simple examples of the MyUrlAction.aspx and MyUrlAction.aspx.cs.
One thing to note here is that some extra controls are used to get the C1 CMS looks on the page.
<%@ Page Language="C#" AutoEventWireup="true" Inherits="MyUrlAction" CodeFile="MyUrlAction.aspx.cs" %> <%@ Register TagPrefix="control" TagName="httpheaders" Src="~/Composite/controls/HttpHeadersControl.ascx" %> <%@ Register TagPrefix="control" TagName="scriptloader" Src="~/Composite/controls/ScriptLoaderControl.ascx" %> <%@ Register TagPrefix="control" TagName="styleloader" Src="~/Composite/controls/StyleLoaderControl.ascx" %> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://www.w3.org/1999/xhtml" xmlns:control="http://www.composite.net/ns/uicontrol"> <control:httpheaders ID="Httpheaders1" runat="server" /> <head> <title>My URL Action</title> <control:styleloader ID="Styleloader1" runat="server" /> <control:scriptloader ID="Scriptloader1" type="sub" runat="server" /> </head> <body> <ui:dialogpage label="My URL Action" image="${skin}/dialogpages/message16.png"> <ui:scrollbox> <asp:PlaceHolder ID="MyPlaceHolder" runat="server" /> </ui:scrollbox> </ui:dialogpage> </body> </html>
And now the MyUrlAction.aspx.cs file:
using System; using System.Linq; using System.Web.UI; using Composite.Data; using Composite.Data.Types; public partial class MyUrlAction : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string pageIdString = this.Request.QueryString["pageId"]; if (pageIdString == null) throw new InvalidOperationException(); Guid pageId = new Guid(pageIdString); using (new DataScope(DataScopeIdentifier.Administrated, UserSettings.ActiveLocaleCultureInfo)) { IPage page = PageManager.GetPageById(pageId); this.MyPlaceHolder.Controls.Add(new LiteralControl("Title: " + page.Title + "<br />")); } } }
You can do all sorts of things here. This is only a very simple and naïve example.