You develop a custom editor for your dynamic element. You would like to enable the Editor to select a link using the same window AxCMS.net 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
- 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 AxCMS.net overview page with PageCall thus reusing a lot of MS GUI.
AxCMS.net versions: all