help.axcms.netAxinom Logo
Save Save Chapter Send Feedback

KB10068: How to create a link selector programmatically

You can reuse an existing link selector (ManageLink) using a PageCall control and some tricks.


You develop a custom editor for your dynamic element. You would like to enable the Editor to select a link using the same window uses (allowing to enter an external link or select a page or a document).


The needed functionality is implemented in ManageLink.aspx. What you need is to call it correctly.

First in the ascx-part of your editor define a PageCall-control:

<AxCMS:PageCall id="linkPageCall" runat="server" ButtonType="LinkButton" Target="_blank" Text="select ..."/>

In code behind wire the ClickAfter event (do it in InitializeComponent):

linkPageCall.ClickAfter += OnLinkPageCallClickAfter;

In Page_Load setup the URL for the PageCall:

linkPageCall.NavigateUrl = CMSConfigurationSettings.CMSApplicationVirtualPath + "/admin/Links/ManageLink.aspx?Popup=1&cb=2";

Note: cb=2 is an important addition. Without it the ClickAfter event will not be called (ManageLink "thinks" then, it is being called from the text editor).

In the ClickAfter event handler read and interpret the result delivered by ManageLink:

private void OnLinkPageCallClickAfter(object obj, ExtendedEventArgs e)

     var linkData = GeneralJSON.Deserialize<ManageLink.LinkData>(e.Name);


LinkData is a structure with the following definition:

public struct LinkData
    [DataMember] public string Element;
    [DataMember] public string MSURL;
    [DataMember] public string LSURL;
    [DataMember] public bool Track;
    [DataMember] public string Target;

Putting it all together

With all pieces of the puzzle in place it works like this:

  • User clicks on the "Select..."-button, rendered by PageCall
  • JavaScript of the PageCall opens a new windows and loads ManageLink.aspx into it, allowing the user to select a link
  • When the user is finished and clicks "Save Link" a JavaScript method makes a JavaScript call in the parent window passing a string with selection results and closes the popup
  • This JavaScript in the parent window simulates an ordinary button click causing that the ClickAfter event of the PageCall is fired and the passed string is available in its EventArgs
  • Defined event handler for ClickAfter is called. Selected link data is available to it.

The whole story looks from the developer point of view not much different as processing an ordinary Button.Click event.

In a similar way you can use any overview page with PageCall thus reusing a lot of MS GUI.

APPLIES TO versions: all