0

I am creating Tridion GUI Extension, in this i have created a button ("InsertCP") in the Ribbon toolbar. The scenario is:

1.User selects any text from the Rich Text Box of the component
2.User clicks the "InsertCP" button from the ribbon toolbar.
3.when the user clicks the button , i am opening my custom aspx page.
4.From the custom aspx page, user can select "Component" and "Component Template".
5.I am storing the selected component and component template tcm id in a variable.
6.I have submit button in the custom aspx page.
7.when the user clicks the submit button, i need to format the selected text as below in the Rich Text box source.

Ex:

<a href="componentid=tcm-00-000, componenttemplateid="tcm-00-000-00">Selected Text</a>

I have done upto the step 6, i am tryng the step 7, when i click the submit button am not able to submit the selected ID.

I am getting these error when i am adding tridion control in my aspx page

My ASPX page:

<html xmlns="http://www.w3.org/1999/xhtml"     xmlns:c="http://www.sdltridion.com/web/ui/controls"> 
<head runat="server">
<title></title>
<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> 
</head>

<div>
    <asp:TextBox ID="txttags" runat="server" Width="800px"      ></asp:TextBox>       
    <asp:Button ID="btnsubmit" runat="server" Text="Submit"     onclick="btnsubmit_Click"  /> 

         <c:button id="InsertButton" runat="server" class="customButton greybutton" label="Insert" />         
</div>

Cs code :

protected void btnsubmit_Click(object sender, EventArgs e)
    {
txttags.Text = "anyvalue.";
}

and java script are same as exiting one.. But i am getting error on runtime.Do i need to add any namespace in cs page.

My CS page will have so many events like below.Cant i use tridion control button for this page.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tridion.ContentManager.CoreService.Client;
using System.Xml.Linq;
using System.Xml;


namespace Somename
{

public partial class Classname
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }


    protected void ddSelectOption_SelectedIndexChanged(object sender, EventArgs e)
    {



    }


    protected void lbPublication_SelectedIndexChanged(object sender, EventArgs e)
    {

    }


    protected void lbPubFolders_SelectedIndexChanged(object sender, EventArgs e)
    {


    }


    protected void lbComponent_SelectedIndexChanged(object sender, EventArgs e)
    {

    }


    protected void lbComponentTemplate_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
SDLBeginner
  • 829
  • 1
  • 7
  • 19

2 Answers2

1

Looking at your update I gather what you want is to create an anchor element based on the information from your ASPX page into the selected text of the Rich Text field of the Component.

To build something like that you can best look at something similar which is available. Simplest example I can think of is the Hyperlink button in the Format ribbon toolbar. That consists of two items:

  1. ..\Tridion\WebUI\Editors\CME\Views\Popups\Link\Link.aspx
  2. ..\Tridion\WebUI\Editors\CME\Views\Popups\Link\Link.js

The magic all happens inside the JavaScript file (as usually is done in these UI extensions). In the initialize() method, the selected part is extracted like so:

var p = this.properties;
var c = p.controls;

// Get selected acronym
p.OldLink = (window.dialogArguments && window.dialogArguments.link) ? window.dialogArguments.link : {};

The post back to the Rich text field is done in the _onOkButtonClicked(event) method like so:

this._buildNewLinkHtml();
this.fireEvent("submit", { link: this.properties.NewLink });
window.close();

You can take a closer look at the rest of the code in the Link.js file and rebuild it to suit your needs.

By the way, looking at the info you want to post back in the href, I would say its easier if you format it a bit more according to some sort of standard, you could for instance place your URIs there like JSON:

<a href="{'component'='tcm:1-23','componenttemplate'='tcm:1-45-32'}">text</a>

Or possibly even abuse the title attribute for your Component Template URI:

<a href="tcm:1-23" title="tcm:1-45-32">text</a>

Since I'm assuming your Component Template code will use these values to do something special with this hyperlink construct.

Edit

The unrecognized tag prefix c error you show in the added image, you can solve by adding the correct namespace reference as I indicated in my answer here. So just add it in your HTML element:

<html xmlns:c="http://www.sdltridion.com/web/ui/controls" xmlns="http://www.w3.org/1999/xhtml"> 

As for the unrecognized cc tag prefix, you shouldn't need to bother with that one, it seems to be resolved at runtime just fine since you are running this inside the Tridion context.

Community
  • 1
  • 1
Bart Koopman
  • 4,835
  • 17
  • 30
  • this was helpful , but i am stucking at one place , how can i submit my selecetion in aspx page to RTF with my submit button. In existing options they are using Tridion control button.So in my case i dont have any tridion control button on my page. if i am trying to create one its not allowing me .Please help – SDLBeginner Aug 09 '12 at 07:25
  • The UI works through the JavaScript framework, so you have to use a Tridion control button or you have to find some way of hooking your button up to the JavaScript yourself. – Bart Koopman Aug 09 '12 at 07:32
  • My question is simillar to [http://stackoverflow.com/questions/9890099/how-to-access-tridion-controls-in-code-behind] . I followed your steps, but error came for me. how Can i use my asp button as a tridion control button. – SDLBeginner Aug 09 '12 at 07:34
  • ok means i need to follow the same steps. but how can i remove the error i am gerrting like : dependencies is not supported. – SDLBeginner Aug 09 '12 at 07:47
  • You can't hook up your own controls to the JavaScript, just use the `c:Button` like is done in the Link.aspx, I've updated my other answer to contain more info about how you can use the Tridion controls in your JavaScript. As for your error I don't know what code you have so I can't solve that (my crystal ball doesn't provide me with an answer at this time ;o) – Bart Koopman Aug 09 '12 at 07:53
  • I have added a pic of my error to my question when i am adding tridion conrol in my aspx page. kindly suggest how can i remove those errors. – SDLBeginner Aug 09 '12 at 08:59
  • Thanks for updating your answer, i used the same ,and then i am able to create tridion controls. but its showing error on runtime.I am editing my codes in question above. – SDLBeginner Aug 10 '12 at 09:15
1

I'll provide a second answer to your updated question, although you are still keeping us a bit in the dark since you only mention you get a runtime error and not what that exactly is (it is impossible for me to provide a good answer if I don't know what error you get).

Your ASPX page should look something like this:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="Example.MyPopup" ClassName="MyPopup" %>
<%@ Import Namespace="Tridion.Web.UI" %>
<%@ Register TagPrefix="ui" Namespace="Tridion.Web.UI.Editors.CME.Controls" Assembly="Tridion.Web.UI.Editors.CME" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html id="MyPopup" class="tridion popup" xmlns:c="http://www.sdltridion.com/web/ui/controls" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>My Popup Example</title>
        <cc:TridionManager runat="server" Editor="ExampleEditor" IsStandAloneView="false">
            <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>
    </head>
    <body>
        <table id="tblHeight" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td id="InputField" valign="top">
                    <table>
                        <tr>
                            <td id="NameLabelCell" nowrap="nowrap">My Label</td>
                            <td><input id="txttags" name="txttags" value="" tabindex="1" /></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr id="FooterRow">
                <td class="footer" align="right">
                    <div class="BtnWrapper">
                        <c:Button ID="BtnOk" runat="server" TabIndex="2" Label="<%$ Resources: Tridion.Web.UI.Strings, OK %>" />
                        <c:Button ID="BtnCancel" runat="server" TabIndex="3" Label="<%$ Resources: Tridion.Web.UI.Strings, Cancel %>" />
                    </div>
                </td>
            </tr>
        </table>
    </body>
</html>

Note: the table markup is copied directly from the Anchor popup, feel free to use divs instead and style them any way you want, the example is meant to show you how to reuse the existing Tridion controls Your CS would then become:

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 Example
{
    [ControlResources("Example.MyPopup")]
    public class MyPopup : PopupView
    {
    }
}

It doesn't contain anything, and it doesn't need to, as all the actions you will be doing in your JavaScript as explained before.

Bart Koopman
  • 4,835
  • 17
  • 30
  • As you said i cant do anything in my CS page. But Bart i am havinf lot of events in my CS page. As i Updated in my Question.somehow can i use this CS page along with the tridion control button . my aspx page is as similar to your demo aspx page. – SDLBeginner Aug 10 '12 at 11:33
  • 1
    No you cannot use your code in the CS together with the Tridion button control, and since you require the Tridion button control since you want to post information back you should rewrite your code in the JavaScript, that is the way SDL Tridion UI extensions work – Bart Koopman Aug 10 '12 at 11:35
  • 1
    Thanks bart for this information, from two days i was going in the wrong direction.Means i need to stat it again using everything in javascript. – SDLBeginner Aug 10 '12 at 11:48