Hi Rainbow Lovers,
It's time to share some interesting techniques for interfacing Rainbow with other code.
I'm sure you could come up with some different ways too !
Anyway, here's one way we do it in our Rainbow Class.
Topic: How do I integrate an ASP.NET page into Rainbow without converting it to a module ?
We assume you have some basic understanding of modules.
The idea is to create a new Module URL REDIRECT whose job is to link to a asp.net page at runtime.
The Admin configures the Module Settings: url=....hellorainbow.aspx to specify the target page.
The target page is changed to inherit from Rainbow.UI.Page and any header / footer stuff is removed.
When a new Tab Page is created, the URL Redirect module is added to the page and then configured to point to the
target page: hellorainbow.aspx
This page only displays Hello Rainbow World in the content section with the Rainbow Header and Footer.
This can easily be extended to do form processing with postbacks within the Rainbow environment.
1. Create a new module ( User control ) which inherits from OneFileModule
( sorry this is NOT a private assembly module )
./DesktopModules/urlredirect.ascx
<%@ Control language="c#" Inherits="Rainbow.DesktopModules.OneFileModule" %>
<%@ Register TagPrefix="cc1" Namespace="Rainbow.UI.WebControls" Assembly="Rainbow" %>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
InitSettings(SettingsType.Str);
if (SettingsExists)
{
//lblUrl.Text = GetSetting("URL");
Response.Redirect(GetSetting("URL"));
}
}
</script>
<cc1:DesktopModuleTitle EditText="Edit" EditUrl="/chaz/DesktopModules/PropertyPage.aspx" PropertiesText="PROPERTIES" PropertiesUrl="/chaz/DesktopModules/PropertyPage.aspx" runat="server" ID="ModuleTitle" />
<b>Setting Url:</b>
<asp:label id="lblUrl" runat="server" /><br>
2. Use Admin All to register the module ( right most pane - Add module icon )
Friendly Name: Url Redirect
Desktop Datasource: DesktopModules/urlredirect.ascx
3. Create the "Hello Rainbow World" hellorainbow.aspx page which uses the Rainbow header / footer controls
So add this page to your applications folder: e.g. rainbow/mycustom
rainbow/mycustom/hellorainbow.aspx
rainbow/mycustom/hellorainbow.aspx,cs
and rebuild Rainbow
<%@ Page language="c#" Codebehind="hellorainbow.aspx.cs" AutoEventWireup="false" Inherits="Rainbow.mycustom.hellorainbow" %>
<%@ Register TagPrefix="uc1" TagName="DesktopPortalBanner" Src="../Design/DesktopLayouts/DesktopPortalBanner.ascx" %>
<%@ Register TagPrefix="uc1" TagName="DesktopFooter" Src="../Design/DesktopLayouts/DesktopFooter.ascx" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<Head id="htmlHead" runat=server>
<title>
</title>
</Head>
<body>
<form id="Form1" method="post" runat="server">
<uc1:DesktopPortalBanner id="DesktopPortalBanner1" runat="server"></uc1:DesktopPortalBanner>
Hello Rainbow World!
<uc1:DesktopFooter id="DesktopFooter1" runat="server"></uc1:DesktopFooter>
</form>
</body>
</HTML>
codebehind page: NOTE: this is a dummy page which does nothing.
The only thing to note is the rainbow page inheritance
public class hellorainbow : Rainbow.UI.Page
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Rainbow.mycustom
{
/// <summary>
/// Summary description for hellorainbow.
/// </summary>
public class hellorainbow : Rainbow.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#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
}
}
4. Now let's use the new URL REDIRECT module on a new tab page.
Using the Admin This interface:
Add a new Tab named for the target hellorainbow.aspx page
add this Url Redirect module to the center pane
set Specific Module settings
Site Settings String: URL=/Rainbow/mycustom/hellorainbow.aspx
NOTE: setting the Key/value pair URL = .....
will cause the Url Redirect Module to redirect to this page at RunTime.
The Rainbow Header / Footer will still show and the User's can't tell that this content
is not based on rainbow modules design.
Happy Rainbow Coding,
Would you believe ... GetSmartPaul
GetSmartPaul@gmail.com
September 24, 2004