+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / RadComboBox client API issue in LinksEditorDialog.ascx

RadComboBox client API issue in LinksEditorDialog.ascx

8 posts, 0 answered
  1. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    20 Jan 2011
    Link to this post
    Hi,
    I'm trying to add a RadComboBox in the LinksEditorDialog.ascx file to allow setting the link's "target" attribute but the client side API doesn't seem to work. I can't seem to access  the combobox in initDialog(). If I use the ClientID I get an object which doesn't have any of the client API properties/methods:
    var targetBox = document.getElementById('<%= linkTargetBox .ClientID %>');
    alert(targetBox); // "[object HTMLDivElement]"

    If I use the global array I get an undefined item:
    var targetBox = Telerik.Web.UI.RadComboBox.ComboBoxes[0];
    alert(targetBox); // "undefined"

    The box declaration:
    ...
    <li>
        <asp:Label ID="Label4" runat="server" Text="Link target" AssociatedControlID="linkTargetBox">
    </asp:Label>
            <telerik:RadComboBox runat="server" ID="linkTargetBox" EnableEmbeddedSkins="true" Skin="WebBlue">
                <Items>
                    <telerik:RadComboBoxItem Text="Target" Value="" />
                    <telerik:RadComboBoxItem Text="New Window" Value="_blank" />
                    <telerik:RadComboBoxItem Text="Parent Window" Value="_parent" />
                    <telerik:RadComboBoxItem Text="Same Window" Value="_self" />
                    <telerik:RadComboBoxItem Text="Browser Window" Value="_top" />
                </Items>
            </telerik:RadComboBox>
        </li>
    ...
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Jan 2011
    Link to this post
    Hi Alessio S.,

    Can you please try using var targetBox = $find('<%= linkTargetBox .ClientID %>'); to get the component instead of the DOM element. This will give you the JavaScript object which represents your RadComboBox.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    24 Jan 2011
    Link to this post
    Using $find it returns null. It's very strange because inspecting the HTML I see the ClientID is computer correctly, i.e. in the rendered page there is a div matching the resolved ID and it looks like the outer div of the RadComboBox. But doesn't get picked up.

    Not sure if it's relevant but I've put the code in the JS function initDialog(), where there is other JS code operating on the other fields of the dialog with no problems.
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 Jan 2011
    Link to this post
    Hello Alessio S.,

    Can you please provide the whole code for the template. I am using $find in the insertLink method and it is returning the correct object:
    <%@ Register Assembly="Telerik.Libraries" Namespace="Telerik.Libraries.WebControls" TagPrefix="sfLib" %>
     
    <script type="text/javascript">
    var currentElement = document.createElement("a");
    var selectedHtml = "";
     
    function getRadWindow() //mandatory for the RadWindow dialogs functionality
    {
       if (window.radWindow)
        {
        return window.radWindow;
        }
        if (window.frameElement && window.frameElement.radWindow)
        {
         return window.frameElement.radWindow;
        }
        return null;
    }
     
    function initDialog() //called when the dialog is initialized
    {
       var clientParameters = getRadWindow().ClientParameters; //return the arguments supplied from the parent page
     
       if (clientParameters.nodeName && typeof(clientParameters.nodeName) != "undefined" && clientParameters.nodeName == "A")
       {
           currentElement = clientParameters;
               
           urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
           titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
           titleLi = document.getElementById("linkText");
           tooltipTxt = document.getElementById('<%= tooltipTextBox.ClientID %>');
     
           if (currentElement.attributes["sfref"] != undefined) {
            urlTxt.value = currentElement.attributes["sfref"].value;
           }
           else if (currentElement.href != "") {
            urlTxt.value = currentElement.href;
           }
           if (currentElement.title != "")
           {
                tooltipTxt.value = currentElement.title;
           }
           if (currentElement.innerHTML != "")
           {
               htmlText = currentElement.innerHTML;
               if (currentElement.childNodes.length > 1)
               {
                    titleLi.style.display = "none";
                    selectedHtml = htmlText
               }
               else
               {
                    titleTxt.value = htmlText;
               }
           }
       }
       else
       {
           titleLi = document.getElementById("linkText");
           titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
            
           //TELERIK
           htmlText = clientParameters.Html;
           if (clientParameters.Html.indexOf("<IMG ") != -1 || clientParameters.Html.indexOf("<img ") != -1)
            selectedHtml = clientParameters.Html;                   
           pureText = clientParameters.Text;
           titleTxt.value = pureText;
            
           document.getElementById('linkURL').getElementsByTagName('input')[0].focus();
       }
       requiredFieldsValidate();
    }
     
    if (window.attachEvent)
    {
       window.attachEvent("onload", initDialog);
    }
    else if (window.addEventListener)
    {
       window.addEventListener("load", initDialog, false);
    }
     
    function insertLink() //fires when the Insert Link button is clicked
    {
        var targetBox = $find('<%= linkTargetBox .ClientID %>');
       var closeArgument = currentElement;
       urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
       titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
       titleLi = document.getElementById("linkText");
       tooltipTxt = document.getElementById('<%= tooltipTextBox.ClientID %>');
     
       if (urlTxt) {
        closeArgument.href = urlTxt.value;
        if (urlTxt.value.indexOf("~/") == 0 || urlTxt.value.indexOf("[") == 0) {
            closeArgument.setAttribute("sfref", urlTxt.value);
        } else {
            closeArgument.removeAttribute("sfref");
        }
       }
        
       if (selectedHtml != "")
       {
            closeArgument.innerHTML = selectedHtml;
       }
       else if (titleTxt && titleLi.style.display != "none")
       {
            closeArgument.innerHTML = titleTxt.value;
       }  
        
       if (tooltipTxt && tooltipTxt.value != "")
            closeArgument.title = tooltipTxt.value;
        
       var radWindow = getRadWindow();
       radWindow.argument = closeArgument;
       radWindow.close(closeArgument); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.
    }
     
    function beforeInsertLink(src, altText, title)
    {
        if (src != '')
        {
            urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
            titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
            if (urlTxt && titleTxt)
            {
                urlTxt.value = src;
                if(titleTxt.value == "")
                    titleTxt.value = title;
            }
        }
        requiredFieldsValidate();
    }
    </script>
    <div class="ctrlProps" id="div1">
    <div class="ctrlContent">
    <div class="uploadPane">
    <p class="mand">* Mandatory fields</p>
    <h2>Insert a link</h2>
     
    <div  class="dialogBox">
     
        <ol> <li id="linkURL">
            
                <asp:Label ID="Label1" runat="server" Text="<%$Resources:Url %>" AssociatedControlID="urlTextBox"></asp:Label>
                <asp:TextBox runat="server" ID="urlTextBox" onkeydown="requiredFieldsValidate();" onkeyup="requiredFieldsValidate(); return false; " onfocus="requiredFieldsValidate(); return false; " onblur="requiredFieldsValidate(); return false; "></asp:TextBox>
                <asp:Label runat="server" Text="<%$Resources:Or %>"></asp:Label>
                <sfLib:ButtonSelector runat="server" ID="selectFromExistingLink" ButtonText="<%$Resources:SelectFromExisting %>" WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/PagesSelector.aspx" AssociatedControls="urlTextBox" />
                <p class="example"><asp:Literal ID="Label2" runat="server" Text="<%$Resources:UrlExpl %>" ></asp:Literal></p>
       
          </li>
            <li id="linkText">
                <asp:Label runat="server" Text="<%$Resources:Text %>" AssociatedControlID="linkTextBox"></asp:Label>
                <asp:TextBox runat="server" ID="linkTextBox" onkeydown="requiredFieldsValidate();" onkeyup="requiredFieldsValidate(); return false; " onfocus="requiredFieldsValidate(); return false; " onblur="requiredFieldsValidate(); return false; "></asp:TextBox>
                <p class="example"><asp:Literal ID="Literal1" runat="server" Text="<%$Resources:TextExpl %>" ></asp:Literal></p>
            </li>
            <li>
                <asp:Label ID="Label3" runat="server" Text="<%$Resources:Tooltip %>" AssociatedControlID="tooltipTextBox"></asp:Label>
                <asp:TextBox runat="server" ID="tooltipTextBox"></asp:TextBox>         
                <p class="example"><asp:Literal ID="Literal2" runat="server" Text="<%$Resources:TooltipExpl %>" ></asp:Literal></p>
            </li>
            <li>
                <asp:Label ID="Label4" runat="server" Text="Link target" AssociatedControlID="linkTargetBox">
                </asp:Label>
                <telerik:RadComboBox runat="server" ID="linkTargetBox" EnableEmbeddedSkins="true" Skin="WebBlue">
                    <Items>
                        <telerik:RadComboBoxItem Text="Target" Value="" />
                        <telerik:RadComboBoxItem Text="New Window" Value="_blank" />
                        <telerik:RadComboBoxItem Text="Parent Window" Value="_parent" />
                        <telerik:RadComboBoxItem Text="Same Window" Value="_self" />
                        <telerik:RadComboBoxItem Text="Browser Window" Value="_top" />
                    </Items>
                </telerik:RadComboBox>
            </li>
        </ol>
     
    <p runat="server" id="actionButtons" class="button_area bottom">
        <span class="CmsButLeft disabled ok" id="submitBtnDisenabled"><strong class="CmsButRight light">Insert</strong></span>
        <a href="#" onclick="insertLink();" style="display: none; " class="CmsButLeft ok" id="submitBtnEnabled"><strong class="CmsButRight light"><asp:Literal runat="server" Text="<%$Resources:Insert %>"></asp:Literal></strong></a>
        <span class="cmsorlbl"> <asp:Literal runat="server" Text="<%$Resources:Or %>"></asp:Literal> </span>
        <a href="#" onclick="getRadWindow().close();" class="cmscclcmd"><asp:Literal runat="server" Text="<%$Resources:Cancel %>"></asp:Literal></a>
    </p>
    <script type="text/javascript">
    var lURL = document.getElementById("linkURL").getElementsByTagName("input")[0];
    var lText = document.getElementById("linkText").getElementsByTagName("input")[0];
    var textLi = document.getElementById("linkText");
    var submitBtnEnabled = document.getElementById("submitBtnEnabled");
    var submitBtnDisenabled = document.getElementById("submitBtnDisenabled");
     
    function requiredFieldsValidate() {
        if(lURL.value == "" || (textLi.style.display != "none" && lText.value == "")) {
            submitBtnEnabled.style.display = "none";
            submitBtnDisenabled.style.display = "block";
        } else {
            submitBtnEnabled.style.display = "block";
            submitBtnDisenabled.style.display = "none";
        }
             
    }
    </script>
    </div>
    </div>
    </div>
    </div>


    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    24 Jan 2011
    Link to this post
    <%@ Register Assembly="Telerik.Libraries" Namespace="Telerik.Libraries.WebControls"
        TagPrefix="sfLib" %>
    <script type="text/javascript">
        var currentElement = document.createElement("a");
        var selectedHtml = "";
     
        function getRadWindow() //mandatory for the RadWindow dialogs functionality
        {
            if (window.radWindow) {
                return window.radWindow;
            }
            if (window.frameElement && window.frameElement.radWindow) {
                return window.frameElement.radWindow;
            }
            return null;
        }
     
        function initDialog() //called when the dialog is initialized
        {
            var clientParameters = getRadWindow().ClientParameters; //return the arguments supplied from the parent page
             
            if (clientParameters.nodeName && typeof (clientParameters.nodeName) != "undefined" && clientParameters.nodeName == "A") {
                currentElement = clientParameters;
     
                urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
                titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
                titleLi = document.getElementById("linkText");
                tooltipTxt = document.getElementById('<%= tooltipTextBox.ClientID %>');
                var targetBox = $find('<%= linkTargetBox.ClientID %>');
                 
                if (currentElement.attributes["sfref"] != undefined) {
                    urlTxt.value = currentElement.attributes["sfref"].value;
                }
                else if (currentElement.href != "") {
                    urlTxt.value = currentElement.href;
                }
                if (currentElement.title != "") {
                    tooltipTxt.value = currentElement.title;
                }
                if (currentElement.innerHTML != "") {
                    htmlText = currentElement.innerHTML;
                    if (currentElement.childNodes.length > 1) {
                        titleLi.style.display = "none";
                        selectedHtml = htmlText
                    }
                    else {
                        titleTxt.value = htmlText;
                    }
                }
                var tg = currentElement.getAttribute("target");
                if (tg == "Target") tg = "";
                //alert(tg);
                //alert(targetBox);
                if (tg != null) {
                    targetBox.FindItemByValue(tg).Select();
                }
                //alert(targetBox.SelectedItem);
            }
            else {
                titleLi = document.getElementById("linkText");
                titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
                var targetBox = $find('<%= linkTargetBox.ClientID %>');
     
                //TELERIK
                htmlText = clientParameters.Html;
                if (clientParameters.Html.indexOf("<IMG ") != -1 || clientParameters.Html.indexOf("<img ") != -1)
                    selectedHtml = clientParameters.Html;
                pureText = clientParameters.Text;
                titleTxt.value = pureText;
     
                document.getElementById('linkURL').getElementsByTagName('input')[0].focus();
     
                targetBox.FindItemByValue("").Select();
            }
            requiredFieldsValidate();
        }
     
        if (window.attachEvent) {
            window.attachEvent("onload", initDialog);
        }
        else if (window.addEventListener) {
            window.addEventListener("load", initDialog, false);
        }
         
        function insertLink() //fires when the Insert Link button is clicked
        {
            var closeArgument = currentElement;
            urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
            titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
            titleLi = document.getElementById("linkText");
            tooltipTxt = document.getElementById('<%= tooltipTextBox.ClientID %>');
            var targetBox = $find('<%= linkTargetBox.ClientID %>');
     
            if (urlTxt) {
                closeArgument.href = urlTxt.value;
                if (urlTxt.value.indexOf("~/") == 0 || urlTxt.value.indexOf("[") == 0) {
                    closeArgument.setAttribute("sfref", urlTxt.value);
                } else {
                    closeArgument.removeAttribute("sfref");
                }
            }
     
            if (selectedHtml != "") {
                closeArgument.innerHTML = selectedHtml;
            }
            else if (titleTxt && titleLi.style.display != "none") {
                closeArgument.innerHTML = titleTxt.value;
            }
     
            if (tooltipTxt && tooltipTxt.value != "")
                closeArgument.title = tooltipTxt.value;
     
            if (targetBox.SelectedItem.Value != "") {
                closeArgument.setAttribute("target", targetBox.SelectedItem.Value);
            } else {
                closeArgument.removeAttribute("target");
            }
     
            var radWindow = getRadWindow();
            radWindow.argument = closeArgument;
            radWindow.close(closeArgument); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.
        }
     
        function beforeInsertLink(src, altText, title) {
            if (src != '') {
                urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
                titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
                if (urlTxt && titleTxt) {
                    urlTxt.value = src;
                    if (titleTxt.value == "")
                        titleTxt.value = title;
                }
            }
            requiredFieldsValidate();
        }
    </script>
    <div class="ctrlProps" id="div1">
        <div class="ctrlContent">
            <div class="uploadPane">
                <p class="mand">
                    * Mandatory fields</p>
                <h2>
                    Insert a link</h2>
                <div class="dialogBox">
                    <ol>
                        <li id="linkURL">
                            <asp:Label ID="Label1" runat="server" Text="<%$Resources:Url %>" AssociatedControlID="urlTextBox"></asp:Label>
                            <asp:TextBox runat="server" ID="urlTextBox" onkeydown="requiredFieldsValidate();"
                                onkeyup="requiredFieldsValidate(); return false; " onfocus="requiredFieldsValidate(); return false; "
                                onblur="requiredFieldsValidate(); return false; "></asp:TextBox>
                            <asp:Label runat="server" Text="<%$Resources:Or %>"></asp:Label>
                            <sfLib:ButtonSelector runat="server" ID="selectFromExistingLink" ButtonText="<%$Resources:SelectFromExisting %>"
                                WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/PagesSelector.aspx" AssociatedControls="urlTextBox" />
                            <p class="example">
                                <asp:Literal ID="Label2" runat="server" Text="<%$Resources:UrlExpl %>"></asp:Literal></p>
                        </li>
                        <li id="linkText">
                            <asp:Label runat="server" Text="<%$Resources:Text %>" AssociatedControlID="linkTextBox"></asp:Label>
                            <asp:TextBox runat="server" ID="linkTextBox" onkeydown="requiredFieldsValidate();"
                                onkeyup="requiredFieldsValidate(); return false; " onfocus="requiredFieldsValidate(); return false; "
                                onblur="requiredFieldsValidate(); return false; "></asp:TextBox>
                            <p class="example">
                                <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:TextExpl %>"></asp:Literal></p>
                        </li>
                        <li>
                            <asp:Label ID="Label3" runat="server" Text="<%$Resources:Tooltip %>" AssociatedControlID="tooltipTextBox"></asp:Label>
                            <asp:TextBox runat="server" ID="tooltipTextBox"></asp:TextBox>
                            <p class="example">
                                <asp:Literal ID="Literal2" runat="server" Text="<%$Resources:TooltipExpl %>"></asp:Literal></p>
                        </li>
                        <li>
                            <asp:Label ID="Label4" runat="server" Text="Target (in quale finestra viene aperto il link)" AssociatedControlID="linkTargetBox"></asp:Label>
                            <telerik:RadComboBox runat="server" ID="linkTargetBox" EnableEmbeddedSkins="true"
                                Skin="WebBlue">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Target" Value="" />
                                    <telerik:RadComboBoxItem Text="New Window" Value="_blank" />
                                    <telerik:RadComboBoxItem Text="Parent Window" Value="_parent" />
                                    <telerik:RadComboBoxItem Text="Same Window" Value="_self" />
                                    <telerik:RadComboBoxItem Text="Browser Window" Value="_top" />
                                </Items>
                            </telerik:RadComboBox>
                        </li>
                    </ol>
                    <p runat="server" id="actionButtons" class="button_area bottom">
                        <span class="CmsButLeft disabled ok" id="submitBtnDisenabled"><strong class="CmsButRight light">
                            Insert</strong></span> <a href="#" onclick="insertLink();" style="display: none;"
                                class="CmsButLeft ok" id="submitBtnEnabled"><strong class="CmsButRight light">
                                    <asp:Literal runat="server" Text="<%$Resources:Insert %>"></asp:Literal></strong></a>
                        <span class="cmsorlbl">
                            <asp:Literal runat="server" Text="<%$Resources:Or %>"></asp:Literal>
                        </span><a href="#" onclick="getRadWindow().close();" class="cmscclcmd">
                            <asp:Literal runat="server" Text="<%$Resources:Cancel %>"></asp:Literal></a>
                    </p>
                    <script type="text/javascript">
                        var lURL = document.getElementById("linkURL").getElementsByTagName("input")[0];
                        var lText = document.getElementById("linkText").getElementsByTagName("input")[0];
                        var textLi = document.getElementById("linkText");
                        var submitBtnEnabled = document.getElementById("submitBtnEnabled");
                        var submitBtnDisenabled = document.getElementById("submitBtnDisenabled");
     
                        function requiredFieldsValidate() {
                            if (lURL.value == "" || (textLi.style.display != "none" && lText.value == "")) {
                                submitBtnEnabled.style.display = "none";
                                submitBtnDisenabled.style.display = "block";
                            } else {
                                submitBtnEnabled.style.display = "block";
                                submitBtnDisenabled.style.display = "none";
                            }
     
                        }
                    </script>
                </div>
            </div>
        </div>
    </div>
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    26 Jan 2011
    Link to this post
    Hi Alessio S.,

    The problem on your side is that you are calling the findItemByValue with upper case F. Please note that method names are case sensitive in JavaScript. the actual method starts with lower case f:
    <%@ Register Assembly="Telerik.Libraries" Namespace="Telerik.Libraries.WebControls"
        TagPrefix="sfLib" %>
    <script type="text/javascript">
        var currentElement = document.createElement("a");
        var selectedHtml = "";
     
        function getRadWindow() //mandatory for the RadWindow dialogs functionality
        {
            if (window.radWindow) {
                return window.radWindow;
            }
            if (window.frameElement && window.frameElement.radWindow) {
                return window.frameElement.radWindow;
            }
            return null;
        }
     
        function initDialog() //called when the dialog is initialized
        {
            var clientParameters = getRadWindow().ClientParameters; //return the arguments supplied from the parent page
     
            if (clientParameters.nodeName && typeof (clientParameters.nodeName) != "undefined" && clientParameters.nodeName == "A") {
                currentElement = clientParameters;
     
                urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
                titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
                titleLi = document.getElementById("linkText");
                tooltipTxt = document.getElementById('<%= tooltipTextBox.ClientID %>');
                var targetBox = $find('<%= linkTargetBox.ClientID %>');
     
                if (currentElement.attributes["sfref"] != undefined) {
                    urlTxt.value = currentElement.attributes["sfref"].value;
                }
                else if (currentElement.href != "") {
                    urlTxt.value = currentElement.href;
                }
                if (currentElement.title != "") {
                    tooltipTxt.value = currentElement.title;
                }
                if (currentElement.innerHTML != "") {
                    htmlText = currentElement.innerHTML;
                    if (currentElement.childNodes.length > 1) {
                        titleLi.style.display = "none";
                        selectedHtml = htmlText
                    }
                    else {
                        titleTxt.value = htmlText;
                    }
                }
                var tg = currentElement.getAttribute("target");
                if (tg == "Target") tg = "";
                //alert(tg);
                //alert(targetBox);
                if (tg != null) {
                    targetBox.findItemByValue(tg).Select();
                }
                //alert(targetBox.SelectedItem);
            }
            else {
                titleLi = document.getElementById("linkText");
                titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
                var targetBox = $find('<%= linkTargetBox.ClientID %>');
     
                //TELERIK
                htmlText = clientParameters.Html;
                if (clientParameters.Html.indexOf("<IMG ") != -1 || clientParameters.Html.indexOf("<img ") != -1)
                    selectedHtml = clientParameters.Html;
                pureText = clientParameters.Text;
                titleTxt.value = pureText;
     
                document.getElementById('linkURL').getElementsByTagName('input')[0].focus();
     
                targetBox.findItemByValue("").Select();
            }
            requiredFieldsValidate();
        }
     
        if (window.attachEvent) {
            window.attachEvent("onload", initDialog);
        }
        else if (window.addEventListener) {
            window.addEventListener("load", initDialog, false);
        }
     
        function insertLink() //fires when the Insert Link button is clicked
        {
            var closeArgument = currentElement;
            urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
            titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
            titleLi = document.getElementById("linkText");
            tooltipTxt = document.getElementById('<%= tooltipTextBox.ClientID %>');
            var targetBox = $find('<%= linkTargetBox.ClientID %>');
     
            if (urlTxt) {
                closeArgument.href = urlTxt.value;
                if (urlTxt.value.indexOf("~/") == 0 || urlTxt.value.indexOf("[") == 0) {
                    closeArgument.setAttribute("sfref", urlTxt.value);
                } else {
                    closeArgument.removeAttribute("sfref");
                }
            }
     
            if (selectedHtml != "") {
                closeArgument.innerHTML = selectedHtml;
            }
            else if (titleTxt && titleLi.style.display != "none") {
                closeArgument.innerHTML = titleTxt.value;
            }
     
            if (tooltipTxt && tooltipTxt.value != "")
                closeArgument.title = tooltipTxt.value;
     
            if (targetBox.SelectedItem.Value != "") {
                closeArgument.setAttribute("target", targetBox.SelectedItem.Value);
            } else {
                closeArgument.removeAttribute("target");
            }
     
            var radWindow = getRadWindow();
            radWindow.argument = closeArgument;
            radWindow.close(closeArgument); //use the close function of the getRadWindow to close the dialog and pass the arguments from the dialog to the callback function on the main page.
        }
     
        function beforeInsertLink(src, altText, title) {
            if (src != '') {
                urlTxt = document.getElementById('<%= urlTextBox.ClientID %>');
                titleTxt = document.getElementById('<%= linkTextBox.ClientID %>');
                if (urlTxt && titleTxt) {
                    urlTxt.value = src;
                    if (titleTxt.value == "")
                        titleTxt.value = title;
                }
            }
            requiredFieldsValidate();
        }
    </script>
    <div class="ctrlProps" id="div1">
        <div class="ctrlContent">
            <div class="uploadPane">
                <p class="mand">
                    * Mandatory fields</p>
                <h2>
                    Insert a link</h2>
                <div class="dialogBox">
                    <ol>
                        <li id="linkURL">
                            <asp:Label ID="Label1" runat="server" Text="<%$Resources:Url %>" AssociatedControlID="urlTextBox"></asp:Label>
                            <asp:TextBox runat="server" ID="urlTextBox" onkeydown="requiredFieldsValidate();"
                                onkeyup="requiredFieldsValidate(); return false; " onfocus="requiredFieldsValidate(); return false; "
                                onblur="requiredFieldsValidate(); return false; "></asp:TextBox>
                            <asp:Label ID="Label11" runat="server" Text="<%$Resources:Or %>"></asp:Label>
                            <sfLib:ButtonSelector runat="server" ID="selectFromExistingLink" ButtonText="<%$Resources:SelectFromExisting %>"
                                WindowNavigateUrl="~/Sitefinity/UserControls/Dialogs/PagesSelector.aspx" AssociatedControls="urlTextBox" />
                            <p class="example">
                                <asp:Literal ID="Label2" runat="server" Text="<%$Resources:UrlExpl %>"></asp:Literal></p>
                        </li>
                        <li id="linkText">
                            <asp:Label ID="Label22" runat="server" Text="<%$Resources:Text %>" AssociatedControlID="linkTextBox"></asp:Label>
                            <asp:TextBox runat="server" ID="linkTextBox" onkeydown="requiredFieldsValidate();"
                                onkeyup="requiredFieldsValidate(); return false; " onfocus="requiredFieldsValidate(); return false; "
                                onblur="requiredFieldsValidate(); return false; "></asp:TextBox>
                            <p class="example">
                                <asp:Literal ID="Literal11" runat="server" Text="<%$Resources:TextExpl %>"></asp:Literal></p>
                        </li>
                        <li>
                            <asp:Label ID="Label3" runat="server" Text="<%$Resources:Tooltip %>" AssociatedControlID="tooltipTextBox"></asp:Label>
                            <asp:TextBox runat="server" ID="tooltipTextBox"></asp:TextBox>
                            <p class="example">
                                <asp:Literal ID="Literal2" runat="server" Text="<%$Resources:TooltipExpl %>"></asp:Literal></p>
                        </li>
                        <li>
                            <asp:Label ID="Label4" runat="server" Text="Target (in quale finestra viene aperto il link)" AssociatedControlID="linkTargetBox"></asp:Label>
                            <telerik:RadComboBox runat="server" ID="linkTargetBox" EnableEmbeddedSkins="true"
                                Skin="WebBlue">
                                <Items>
                                    <telerik:RadComboBoxItem Text="Target" Value="" />
                                    <telerik:RadComboBoxItem Text="New Window" Value="_blank" />
                                    <telerik:RadComboBoxItem Text="Parent Window" Value="_parent" />
                                    <telerik:RadComboBoxItem Text="Same Window" Value="_self" />
                                    <telerik:RadComboBoxItem Text="Browser Window" Value="_top" />
                                </Items>
                            </telerik:RadComboBox>
                        </li>
                    </ol>
                    <p runat="server" id="actionButtons" class="button_area bottom">
                        <span class="CmsButLeft disabled ok" id="submitBtnDisenabled"><strong class="CmsButRight light">
                            Insert</strong></span> <a href="#" onclick="insertLink();" style="display: none;"
                                class="CmsButLeft ok" id="submitBtnEnabled"><strong class="CmsButRight light">
                                    <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:Insert %>"></asp:Literal></strong></a>
                        <span class="cmsorlbl">
                            <asp:Literal ID="Literal22" runat="server" Text="<%$Resources:Or %>"></asp:Literal>
                        </span><a href="#" onclick="getRadWindow().close();" class="cmscclcmd">
                            <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:Cancel %>"></asp:Literal></a>
                    </p>
                    <script type="text/javascript">
                        var lURL = document.getElementById("linkURL").getElementsByTagName("input")[0];
                        var lText = document.getElementById("linkText").getElementsByTagName("input")[0];
                        var textLi = document.getElementById("linkText");
                        var submitBtnEnabled = document.getElementById("submitBtnEnabled");
                        var submitBtnDisenabled = document.getElementById("submitBtnDisenabled");
     
                        function requiredFieldsValidate() {
                            if (lURL.value == "" || (textLi.style.display != "none" && lText.value == "")) {
                                submitBtnEnabled.style.display = "none";
                                submitBtnDisenabled.style.display = "block";
                            } else {
                                submitBtnEnabled.style.display = "block";
                                submitBtnDisenabled.style.display = "none";
                            }
     
                        }
                    </script>
                </div>
            </div>
        </div>
    </div>

    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Alessio S.
    Alessio S. avatar
    37 posts
    Registered:
    31 May 2010
    27 Jan 2011
    Link to this post
    That was a silly mistake, sorry. But it still doesn't work. If I use $find() it returns null and targetBox is null. If I use document.getElementById(), it does find targetBox but it comes back as a DispHTMLDivElement and doesn't have the client API methods and properties. I haven't changed anything else in the file, even compared it with a diff tool with the original template.
  8. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    01 Feb 2011
    Link to this post
    Hi Alessio S.,

    Unfortunately I am not able to reproduce the problem with the markup I have sent you. The combobox item is properly found and its client side API is resolved.

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Register for webinar
8 posts, 0 answered