I am customizing the Tridion ribbon toolbar to add a button. How can I access Tridion controls like button and dropdown inside my .NET ASPX page?
-
1Could you perhaps explain a little more about what your ASPX page needs to do? Is it a popup which is opened from clicking on a custom button in the ribbon? – Chris Summers Mar 27 '12 at 13:40
-
1Bart is doing an admirable job of explaining how to build a Tridion-based view in a popup window. To make things clearer, can you share the definition of your toolbar button from your Editor's configuration file AND the JavaScript of the command you execute when the button is clicked? – Frank van Puffelen Mar 28 '12 at 01:52
2 Answers
Your question is a bit vague on what exactly you are trying to accomplish, to add a button to the ribbon toolbar you wouldn't need an ASPX page.
But if your ribbon button is opening a popup window in which you want to use Tridion Controls you will have to start with importing the Tridion.Web.UI namespaces.
in your ASPX page you can add:
<%@ Import Namespace="Tridion.Web.UI" %>
<%@ Register TagPrefix="ui" Namespace="Tridion.Web.UI.Editors.CME.Controls" Assembly="Tridion.Web.UI.Editors.CME" %>
In the head of your ASPX page you should mention the tridion manager control:
<cc:tridionmanager runat="server" editor="ExampleEditor" isstandaloneview="true">
<dependencies runat="server">
<dependency runat="server">Tridion.Web.UI.Editors.CME</dependency>
<dependency runat="server">Tridion.Web.UI.Editors.CME.Controls</dependency>
</dependencies>
</cc:tridionmanager>
And then you can use the controls in your page. Be sure not to forget the namespace reference
xmlns:c="http://www.sdltridion.com/web/ui/controls"
Your code behind you should then extend from a Tridion View, for instance the Tridion.Web.UI.Editors.CME.Views.Popups.PopupView
using Tridion.Web.UI.Core;
using Tridion.Web.UI.Controls;
using Tridion.Web.UI.Core.Controls;
using Tridion.Web.UI.Editors.CME.Views.Popups;
namespace Extensions.Example.Views
{
[ControlResources("Extensions.Example.Views.ExampleDialog")]
[ControlResourcesDependency(typeof(Stack))]
public class ExampleDialog : PopupView
{
}
}
It is all possible but not sure about the support level on reusing the Tridion controls. They are not part of a public API for as far as I know and also nothing from it is documented anywhere (you can look at the ASPX pages in the ..\Tridion\web\WebUI\Editors\CME\Views directory, but you have no examples for the code behind stuff which mostly isn't there anyways). So I would actually recommend you, not to reuse the existing controls and in your ASPX page if you want to use .NET here. In that case just use your own controls. If those controls would need access to the Tridion CMS, you should have them use the core service for that.
It is of course possible to just use the Tridion controls in combination with the JavaScript API as is shown in the existing views. If you use a c:Button
control on your page, in the JavaScript code you can access it as follows:
var p = this.properties;
var c = p.controls;
c.BtnExmpl = $controls.getControl($("#BtnID"), "Tridion.Controls.Button");
// add an event handler like this
$evt.addEventHandler(c.BtnExmpl, "click", this.getDelegate(this._onExmplClicked));

- 4,835
- 17
- 30
This post may help you http://www.tridiondeveloper.com/ribbon-item-group
Although I believe the output of any ASPX or ASCX which is stored in an Editor itself is cached, so the preferred method of creating CM functionality is to use JavaScript and background services stored in a Model, You may want to look at the open source PowerTools project for some more ideas (http://code.google.com/p/tridion-2011-power-tools/).

- 10,153
- 1
- 21
- 46