This is a migrated thread and some comments may be shown as answers.

Customizing Hyperlink Manager

16 Answers 738 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ricky
Top achievements
Rank 2
Ricky asked on 31 Jul 2008, 05:35 AM
Hi

Is there a way around so that i can customize the Hyperlink Manager within the Rad Editor.

Actually i want to open the hyperlink manger which should have a list of Link from my data base table, So can anyone help how i can achieve this.

Thanks
Ricky

16 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 31 Jul 2008, 06:26 AM
Hello Ricky,

Here is how to implement the requested solution:

Copy the EditorDialogs folder from the installation to the root of your application and set the ExternalDialogsPath="~/EditorDialogs", e.g.

<telerik:radeditor id="RadEditor1" ExternalDialogsPath="~/EditorDialogs"  runat="server"></telerik:radeditor>

  After that open
the EditorDialogs\LinkManager.ascx dialog and put the following function before the closing script tag:

function ShowCustomDialog() 
{  
    var argument = {};
    //argument.myArg = "test";
    var callbackFunction = function(sender, args)
    {
        var oTextBox = $get("LinkURL"); 
        oTextBox.value = args;       
    }
    var dialogOpener = Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().get_dialogOpener();
     //openUrl(url, argument, width, height, callbackFunction, callbackArgs, title, modal, behaviors, showStatusbar, showTitlebar)
    dialogOpener.openUrl("CustomLinkManager.aspx", argument, 400, 400, callbackFunction, null, "custom link manager", true); 


In this html add a button (the red marked line) that will open the custom dialog from the hyperlink manager by firing the ShowCustomDialog method:

<li style="margin-bottom: 6px;">
       <label for="LinkURL" class="rightAlignedInputLabel" style="width: 100px;">
               <script type="text/javascript">document.write(localization["LinkUrl"]);</script>
       </label>
       <input type="text" id="LinkURL" class="l_input" />
       <input type="button" value="Open My Manager" onclick="ShowCustomDialog();return false;" />
</li>

The next step is to create the
CustomLinkManager.aspx file in the root of the web application. Here is its content:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CustomLinkManager.aspx.cs" Inherits="CustomLinkManager" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
    <title>Untitled Page</title> 
    <script type="text/javascript">   
    function GetImageUrl(listBoxId )   
    {   
        var listbox = document.getElementById( listBoxId );   
        var url = listbox[listbox.selectedIndex].value;   
        if( url != "" )   
        {          
             Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(url); 
        }   
    }   
    </script>  
</head> 
<body> 
    <form id="form1" runat="server"
    <asp:ScriptManager ID="scriptManager1" runat="server"></asp:ScriptManager> 
    <telerik:RadwindowManager id="RadWindowManager1" runat="server"></telerik:RadwindowManager> 
     <TABLE id="Table1" cellSpacing="0" cellPadding="1"  border="0">   
                <tr>  
                <td colspan=2>Select an image:</td>  
                </tr><TR>   
                    <TD>  
                        <asp:ListBox id="ListBox1" runat="server" Width="224px" Rows="8">   
                            <asp:ListItem Value="http://images.mydomain.com/images/Image1.gif">Image1</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image2.gif">Image2</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image3.gif">Image3</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image4.gif">Image4</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image5.gif">Image5</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image6.gif">Image6</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image7.gif">Image7</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image8.gif">Image8</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image9.gif">Image9</asp:ListItem>  
                            <asp:ListItem Value="http://images.mydomain.com/images/Image10.gif">Image10</asp:ListItem>  
                               
                        </asp:ListBox></TD>   
                    <TD vAlign="top">   
                        <Button id="Button1" onclick="return GetImageUrl('<%=this.ListBox1.ClientID%>');" style="BORDER-RIGHT: dimgray 1px solid; BORDER-TOP: dimgray 1px solid; BORDER-LEFT: dimgray 1px solid; WIDTH: 64px; BORDER-BOTTOM: dimgray 1px solid; HEIGHT: 24px" type=button>Insert</Button></TD>   
                </TR>  
            </TABLE>  
    </form> 
</body> 
</html> 


For your convenience I have attached a sample working project here.



Greetings,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ricky
Top achievements
Rank 2
answered on 31 Jul 2008, 06:43 AM
Hi Rumen 

Thanks for the reply, Now i am using a customized dialog box, which can work as a hyperlink manager for me. Now i have ascx which have list of all the hyperlink i need. When i open the custom dialog it show the list. 

I have text box which will have text for linking and a button which is "Link" so i want now when i click on Link the dialog should disappear the linking should happen with given text. I am struggling to get the values back from the ascx control. 

Thanks in advance

Ricky


0
Rumen
Telerik team
answered on 31 Jul 2008, 11:11 AM
Hi Ricky,

If you are using a custom editor dialog then you can close it using the

getRadWindow().close(returnValue); method.

You can use the close method of the getRadWindow object to close the dialog and pass the arguments from the dialog to the callback function on the main page. You can find more information in this help article: Add Custom Dialogs.


Kind regards,
Rumen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ricky
Top achievements
Rank 2
answered on 01 Aug 2008, 01:06 AM
Thanks

thats was really helpful.
0
Nicolaï
Top achievements
Rank 2
answered on 05 Aug 2009, 07:04 AM
Going to make my own link manager using a radwindow, because the hyperlink manager, "out of the box", seems to be way too complicated for my average user...
For example, does your average person even know what a css class is? (No!)
They do not know what "Anchor" means either.
For "target": new window or same window are the only terms they understand...
Most users do not even seem to know of the term "tooltip".

It's a nice box for a web developer, not for a user.

Would be a nice feature to add, some customization options for the link manager... Maybe similar to toolsfile config?
0
Tervel
Telerik team
answered on 05 Aug 2009, 07:53 AM
Hello Nicolai,

In fact there exists a simple mechanism to modify the editor dialogs.
You can easily run a dialog from external location and change it (e.g. hide the rows which you do not need your users to see by using style="display:none").

The demo which discusses this approach in more detail is here:
http://demos.telerik.com/aspnet-ajax/editor/examples/externaldialogspath/defaultcs.aspx

Regards,
Tervel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
eyal
Top achievements
Rank 1
answered on 17 Nov 2009, 09:50 AM
Hi,

I'm facing the same issue. The hyperlink manager has way too many unneeded properties for the application in question. Though, coping the EditorDialogs folder would create over maintenance work. I only need to hide some of the hyperlink manager properties. Copying the whole folder would mean modifying it again with each update release.

br,
eyal 
0
Rumen
Telerik team
answered on 19 Nov 2009, 03:29 PM
Hi Eyal,

Modifications to the RadEditor dialogs are not make often and the solution provided by Tervel is the only possible way to hide elements / controls in the built-in dialogs of RadEditor.

We plan to provide a lite version of the Image and Link managers of RadEditor in the near future which could be helpful for your scenario.

Kind regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Trevor
Top achievements
Rank 2
answered on 22 Jan 2010, 04:35 PM
Your attached sample file is a dead link can you please supply the sample for me to use, I too would like to create a custom hyperlink manager dialogue.

Also,
I was successful in creating a custom dialog for links that can return a URL to the "LinkManager.ascx"
However
When I try to access the same custom dialog from "ImageMap.ascx" performing the same operations I get an error when I submit the form.

<%

@ Page Language="VB" AutoEventWireup="false" CodeFile="mylinks.aspx.vb" Inherits="EditorDialogs_mylinks" %>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

 

<!

 

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

 

<LINK href="../stylesheets/base.css" type="text/css" rel="stylesheet">

 

<

 

html xmlns="http://www.w3.org/1999/xhtml" >

 

<

 

head id="Head1" runat="server">

 

 

<title>Untitled Page</title>

 

 

<script type="text/javascript">

 

function

 

GetRadWindow()

 

{

 

var oWindow = null;

 

 

if (window.radWindow) oWindow = window.radWindow;

 

 

else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;

 

 

return oWindow;

 

}

 

 

function GetImageUrl(listBoxId )

 

{

 

var listbox = document.getElementById( listBoxId );

 

 

 

var url = listbox[listbox.selectedIndex].value;

 

 

if( url != "" )

 

{

Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(url);

 

//getRadWindow().close(url);

 

}

}

 

</script>

 

</

 

head>

 

<

 

body style="margin:10px;">

 

 

<form id="form1" runat="server">

 

 

<asp:ScriptManager ID="scriptManager1" runat="server"></asp:ScriptManager>

 

 

<telerik:RadwindowManager id="RadWindowManager1" runat="server"></telerik:RadwindowManager>

 

 

<TABLE id="Table1" cellSpacing="0" cellPadding="1" border="0" style="width: 100%">

 

 

<tr>

 

 

<td colspan=2>

 

 

<asp:Label ID="Label1" runat="server" CssClass="normalcaption" Text="Select an existing fluid page..."></asp:Label><br /><br /></td>

 

 

</tr><TR>

 

 

<TD>

 

 

<asp:ListBox style="height:200px;" bk="return GetImageUrl('ListBox1');" id="ListBox1" runat="server" Width="100%" Rows="8">

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image1.gif">Image1</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image2.gif">Image2</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image3.gif">Image3</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image4.gif">Image4</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image5.gif">Image5</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image6.gif">Image6</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image7.gif">Image7</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image8.gif">Image8</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image9.gif">Image9</asp:ListItem>

 

 

<asp:ListItem Value="http://images.mydomain.com/images/Image10.gif">Image10</asp:ListItem>

 

 

 

</asp:ListBox></TD>

 

 

 

</

 

tr>

 

 

<tr><td align=center><br /><Button id="Button1" onclick="return GetImageUrl('ListBox1');" style="BORDER-RIGHT: dimgray 1px solid; BORDER-TOP: dimgray 1px solid; BORDER-LEFT: dimgray 1px solid; WIDTH: 64px; BORDER-BOTTOM: dimgray 1px solid; HEIGHT: 24px" type=button>Insert</Button></TD>

 

 

</TR>

 

 

</TABLE>

 

 

</form>

 

</

 

body>

 

</

 

html>

 



Regards,
Trevor
0
Dobromir
Telerik team
answered on 27 Jan 2010, 02:04 PM
Hi Trevor,

If you are using the exact same code for ImageMap dialog the error that occurs is most probably because the URL field's ID used in LinkManager dialog is different than the ImageMap's URL field.
In order to achieve the same functionality you need to modify the callback function to get the right field, e.g.:
var callbackFunction = function(sender, args) {
    var oTextBox = $get("ImageMap_AreaURL");
    oTextBox.value = args;
}

If this is not the case, could you please open a support ticket and attach a sample project that reproduces the problem so we can investigate it further?

In addition, the correct link for the sample project provided by Rumen in his post is:

Sincerely yours,
Dobromir
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Trevor
Top achievements
Rank 2
answered on 28 Jan 2010, 10:50 PM
Bingo!
That was it.

I have one last issue, the sample you supplied works great, however the custom window that opens to display my links from my database does not have a close (x) button on the top right of the window. No window bar at all for that matter. How can I alter this so that there is a close button. The reason is if the user decides they don't want to make any changes they have no way to go back without updating the url.

or even a cancel button would be good. I tried but any command to close the radwindow desires a return parameter which overwrites the url in the linkmanager.

I tried:

var

 

oWindow = getRadWindow();

 

 

oWindow.argument =

null;

 

 

oWindow.close();
and this updates the url to: undefined

 

 




Trevor
0
Dobromir
Telerik team
answered on 01 Feb 2010, 03:53 PM
Hi Trevor,

The custom dialog that is opened is a RadWindow control and you can set its behaviors using set_behaviors() client-side method. Place the following javascript code inside your custom dialog's aspx file:
window.onload = function()
{
    var oWnd = GetRadWindow();//get reference to RadWindow
    oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);//set Close behavior to the window
}

I hope this helps.

All the best,
Dobromir
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Trevor
Top achievements
Rank 2
answered on 02 Feb 2010, 02:46 PM
I placed your javascript code inside my custom dialog's aspx file and it does fire, however it doesn't do anything.
I still do not get a close button visible in my custom dialog.
Here is the code in the LinkManager.ascx that opens the custom dialog:

var dialogOpener = Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().get_dialogOpener();

 

 

 

//openUrl(url, argument, width, height, callbackFunction, callbackArgs, title, modal, behaviors, showStatusbar, showTitlebar)

 

 

 

dialogOpener.openUrl(

 

 

"mylinks.aspx", argument, 300, 300, callbackFunction, null, "My Links", true);
Here is the code in mylinks.aspx

 <

 

html xmlns="http://www.w3.org/1999/xhtml" >

 

 

 

< head id="Head1" runat="server">

 

 

 

<title>Untitled Page</title>

 

 

 

<script type="text/javascript">

 

 

 window.onload =

 

function load_window()

 {

 

var oWnd = getRadWindow();//get reference to RadWindow

 

 

 

 

oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close);

 

 

 

//set Close behavior to the window

 

 

}

 

 

 

function

 

 

 

 

getRadWindow()

 

 

 {

 

if (window.radWindow)

 

 

 {

 

return window.radWindow;

 

 

 }

 

if (window.frameElement && window.frameElement.radWindow)

 

 

 {

 

return window.frameElement.radWindow;

 

 

 }

 

return null;

 

 

 }

 

function GetImageUrl(listBoxId )

 

 

 {

 

var listbox = document.getElementById( listBoxId ); 

 

 

 

var url = listbox[listbox.selectedIndex].value;

 

 

 

 

if( url != "" )

 {

Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(url);

 

 

//getRadWindow().close(url);

 

 

}

 

 

}

 

 

function exit_window( )

 

 

 {

 

 

var oWindow = getRadWindow();

 oWindow.argument =

 

null;

 oWindow.close();

 

//Telerik.Web.UI.Dialogs.CommonDialogScript.get_windowReference().close(Sys.EventArgs.Empty);

 

 

//getRadWindow().close('');

 

 

 

}

 

 

 

</script>

 

 

 

</head>

 

 

 

<body style="margin:10px;">

 

 

 

<form id="form1" runat="server">

 

 

 

<asp:ScriptManager ID="scriptManager1" runat="server"></asp:ScriptManager>

 

 

 

<telerik:RadwindowManager id="RadWindowManager1" runat="server"></telerik:RadwindowManager>

 

 

 

<TABLE id="Table1" cellSpacing="0" cellPadding="1" border="0" style="width: 100%">

 

 

 

<tr> 

 

 

 

<td colspan=2> 

 

 

 

 

<asp:Label ID="Label1" runat="server" CssClass="normalcaption" Text="Select an existing fluid page..." Font-Bold="True"></asp:Label><br /></td>

 

 

 

</tr><TR>

 

 

 

<TD>

 

 

 

<asp:ListBox style="height:200px;" bk="return GetImageUrl('ListBox1');" id="ListBox1" runat="server" Width="100%" Rows="8">

 

 

 

</asp:ListBox></TD> 

 

 

 

</tr>

 

 

 

<tr><td align=center><br /><Button id="Button1" onclick="return GetImageUrl('ListBox1');" style="BORDER-RIGHT: dimgray 1px solid; BORDER-TOP: dimgray 1px solid; BORDER-LEFT: dimgray 1px solid; WIDTH: 64px; BORDER-BOTTOM: dimgray 1px solid; HEIGHT: 24px" type=button>Insert</Button>

 

 

 

 

<Button id="Button2" onclick="return exit_window();" style="BORDER-RIGHT: dimgray 1px solid; BORDER-TOP: dimgray 1px solid; BORDER-LEFT: dimgray 1px solid; WIDTH: 64px; BORDER-BOTTOM: dimgray 1px solid; HEIGHT: 24px" type=button>Close</Button></TD>

 

 

 

</TR>

 

 

 

</TABLE>

 

 

 

</form> 

 

 

 

</body> </html>

 

 

0
Dobromir
Telerik team
answered on 05 Feb 2010, 12:47 PM
Hi Trevor,

Please accept my apologies for missing this in my previous post. By default, the showTitlebar property of the openUrl method is false, thus the Titlebar of the new opened window is not shown and that is why you do not have a (x) for the window. The following example will open the new dialog with visible Titlebar and behaviors Move and Close (if you need only Close the value should be 4).

dialogOpener.openUrl("mylinks.aspx", argument, 300, 300, callbackFunction, null, "My Links", true, 36, false, true);

If you use this declaration of the openUrl method you can skip the window.onload function from my previous post.

Greetings,
Dobromir
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Trevor
Top achievements
Rank 2
answered on 05 Feb 2010, 04:59 PM
Your solution does provide a close button in the custom window, and when the user clicks the close button this should cancel the event however it
updates the url in the linkmanager to null

The user needs the ability to close the window without updating the url in the linkmanager ie. cancel.
0
Dobromir
Telerik team
answered on 09 Feb 2010, 01:40 PM
Hi Trevor,

The callback function registered with the openUrl() method is called whenever the dialog is closed. If it is closed using the (x) from its Titlebar, there are no arguments sent back to the callback function (args is null) and this is the reason why the URL field is updated to null.
You can check (in the callback function) if the provided arguments are correct and then apply the changes, e.g.:
var callbackFunction = function(sender, args)
{
    var oTextBox = $get("LinkURL");
    if(args) oTextBox.value = args;
}


All the best,
Dobromir
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Editor
Asked by
Ricky
Top achievements
Rank 2
Answers by
Rumen
Telerik team
Ricky
Top achievements
Rank 2
Nicolaï
Top achievements
Rank 2
Tervel
Telerik team
eyal
Top achievements
Rank 1
Trevor
Top achievements
Rank 2
Dobromir
Telerik team
Share this question
or