To Create a custom control for your module please follow those steps.
Step 1
In Module > Configuration > CustomAttributes download existing attributes and add the following properties collection.
<property id="MyCustomControl">
<value />
<attribute name="My Custom Control" isEnabled="true" isVisible="true" allowScripts="false">
<control id="CpVirtualUserControl" type="Centralpoint.Web.UI.Controls.CpVirtualUserControl">
<controlProperty name="Parameters" value="" />
<controlProperty name="FormRowIsContainer" value="true" />
<controlProperty name="VirtualPath" value="~/Custom/Forms/MyControl.ascx" />
</control>
</attribute>
</property>
Step 2
Create asp.net page.
<%@ control language="C#" autoeventwireup="true" codefile="MyControl.ascx.cs" inherits="Centralpoint.WebSite.Console.Custom.Forms._MyControl" %>
<fieldset>
<legend> <cp:cplabel id="Cplabel1" runat="server" cssclass="alert" /></legend>
ModuleId: <asp:textbox ID="Textbox1" runat="server" columns="130" readonly="true"/>
</fieldset>
Step 3
Create code behind for your control to function.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Centralpoint;
using Centralpoint.Web;
using Centralpoint.Web.UI;
using Centralpoint.Web.UI.Controls;
namespace Centralpoint.WebSite.Console.Custom.Forms
{
public partial class _MyControl : VirtualUserControl
{
/// <summary>
/// This method provides the event handler for the page load event.
/// </summary>
/// <param name="e">Set to the event arguments.
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
}
/// <summary>
/// This method provides the event handler for the page pre-render event.
/// </summary>
/// <param name="e">Set to the event arguments.
protected override void OnPreRender(EventArgs e)
{
Guid dataId = new Guid(((CpLabel)this.FindPropertyControl("clblDataId")).Text);
clblMyControl.Text = "My Custom Control:";
object value = Centralpoint.Utilities.Database.ExecuteScalar(this.Page.SelectConnectionString,
String.Format("SELECT TOP 1 ModuleId FROM cpsys_DataCurrent WHERE (DataId = '{0}')", dataId));
if (value != null)
txbMyControl.Text = value.ToString();
base.OnPreRender(e);
}
}
}
Keywords: Control, Console
Related CodeSamples Records