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

Forums / Developing with Sitefinity / Problem with querystring params being duplicated by Generic Content control

Problem with querystring params being duplicated by Generic Content control

14 posts, 1 answered
  1. Dave
    Dave avatar
    20 posts
    Registered:
    10 Aug 2010
    25 Jan 2011
    Link to this post
    We are experiencing some strange behavior when adding links with querystrings to a Generic Content control on a page.  Here are the details.

    Steps to Repro:
    1. Create or open a page for edit and drop a Generic Content control onto it.
    2. Click "edit" on the GC control to bring up the editor.
    3. Switch to HTML view and enter the following HTML:

    <p>Some text</p>
    <p><a href="/Events/EventDetails.aspx?articleID=1725" sfref="~/Events/EventDetails.aspx?articleID=1725">Some link</a>.</p>

    Note: The URLs should point to a legitimate page in your site or you will get an exception when you try to save it.  The querystring params should be fine.

    4. Click "I'm done" to save the changes.
    5. Click "edit" on the GC control again, and click the HTML tab again.

    Result: The HTML text is now:

    <p>Some text</p>
    <p><a href="/Events/EventDetails.aspx?articleID=1725?articleID=1725" sfref="~/Events/EventDetails.aspx?articleID=1725?articleID=1725">Some link</a>.</p>

    Expect: The "?articleID=1725" should not be duplicated on the URLs.

    What's more, it continues to append new ones every time you save and re-open it. Is this an actual bug or are we entering these wrong or what?  I search the forums on terms I could think of but could not find anyone else experiencing this.

    Thanks,
    Dave Parker
    Coherent Interactive
    Seattle, WA
  2. Dave
    Dave avatar
    20 posts
    Registered:
    10 Aug 2010
    25 Jan 2011
    Link to this post
    I should also add that this does not happen if I use absolute URLs.  Also, we are on 3.7 SP4, with .NET 3.5.

    Dave Parker
    Coherent Interactive
    Seattle, WA
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Jan 2011
    Link to this post
    Hello Dave,

    Thank you for using our services.

    Can you please open the ~/Sitefinity/Admin/ControlTemplates/Pages/Dialogs/LinksEditorDialog.ascx file and edit the insertLink javascript function:
    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 %>');
     
       if (urlTxt) {
                    closeArgument.href = urlTxt.value;
                    if (urlTxt.value.indexOf("~/") == 0 || urlTxt.value.indexOf("[") == 0) {
            var linkText = urlTxt.value;
                        var index = linkText.indexOf('?');
                        if (index != -1) {
                            linkText = linkText.substring(0, index);
            }
                                    closeArgument.setAttribute("sfref", linkText);
                    } 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.
    }

    This will make the links editor dialog not duplicate query string parameters when you insert links with query strings. Unfortunately you will have to manually fix existing links.

    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
    Answered
  4. Dave
    Dave avatar
    20 posts
    Registered:
    10 Aug 2010
    27 Jan 2011
    Link to this post
    Yep.  That did the trick.  Thank you very much.

    Dave Parker
    Coherent Interactive
    Seattle, WA
  5. Mark
    Mark avatar
    12 posts
    Registered:
    10 Feb 2011
    29 Mar 2011
    Link to this post
    Hi Radoslav, This fix doesn't work in Chrome, can you please provide a solution for Chrome.

    Thanks
    Mark
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    31 Mar 2011
    Link to this post
    Hi Mark,

    Can you please check if you have any JavaScript errors in Chrome? I have tested this solution in Chore and it works perfectly on my end.

    Kind regards,
    Radoslav Georgiev
    the Telerik team
  7. Mark
    Mark avatar
    12 posts
    Registered:
    10 Feb 2011
    01 Apr 2011
    Link to this post
    Hi Radoslav,

    I'm using Google Chrome version 10.0.648.204 and no javascript errors occur.  Sitefinity version is 3.7.2136.240:0

    I've stripped the content back to just a single href and this still occurs.

    First Save

    <a href="/enquiry.aspx?Product_Name=TestProduct">Enquire Now</a>

    Second Save
    <a href="/enquiry.aspx?Product_Name=TestProduct" sfref="~/enquiry.aspx?Product_Name=TestProduct">Enquire Now</a>

    Third Save
    <a href="/enquiry.aspx?Product_Name=TestProduct?Product_Name=TestProduct" sfref="~/enquiry.aspx?Product_Name=TestProduct?Product_Name=TestProduct">Enquire Now</a>

  8. Dave
    Dave avatar
    20 posts
    Registered:
    10 Aug 2010
    02 Apr 2011
    Link to this post
    So, as the original poster of the problem, I have to say I agree with Mark, only it does not work in any browser.  It was some time ago, so I am not sure what I did (wrong) to lead me to believe that the code you supplied solved the problem, but looking at it closer it only fixes the case when you click on the "Insert Link" button on the toolbar and enter a URL from there (it even says that in the comment at the top of the patch code). My post talked about having the problem when editing the markup directly on the HTML tab. When we set a breakpoint inside the patch code, it never gets hit.

    It appears that the code that is actually duplicating the querystrings is deeper than the surface javascript event handlers. The above patch is really just a band-aid that recovers from the error when using a certian path.

    Radoslav, can you retry the problem in SF 3.7 SP4 using the exact repro steps from my original post or perhaps with Mark's most recent post?

    Thanks,
    Dave Parker
    Coherent Interactive
    Seattle, WA

  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    05 Apr 2011
    Link to this post
    Hello Dave,

    Have you made changes to the HTML itself or do you paste the link form somwhere? I do not see the dynamic url added in the a tag. There is a bug in SP4 related to the duplicate query string indeed and it should not appear if you use the link manager that pics pages from the sitemap.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

  10. Mark
    Mark avatar
    12 posts
    Registered:
    10 Feb 2011
    06 Apr 2011
    Link to this post
    I also agree with Dave, this doesn't work in any browser.

    Ivan, the best way to test this is to use the steps from Dave's original post.  I have reproduced this by going into the HTML view and editing the html directly.

    Regards
    Mark
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    06 Apr 2011
    Link to this post
    Hello,

    I managed to replicate the issue and its was logged for fixing. The problem is inside  GeneriContentDesigner class - InitializeControls. There is some issue with the link resolved - LinksParser.ResolveLinks that uses HtmlChunk to resolve the link. We will need some time to investigate the issue and fix it.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

  12. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    15 Jun 2011
    Link to this post
    Telerik,

    Would you please provide an update on this issue? This is a problem for us as well. 
  13. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    15 Jun 2011
    Link to this post
    More information...

    I've implemented the javascript fix, and when I enter my relative URL with querystring, /myGroup/myPage.aspx?myKey=MyValue, Save, and then go to re-edit, I get the "System.Web.HttpException: '/myGroup/myPage.aspx?myKey=MyValue' is not a valid virtual path." exception.

    Please update on a fix.
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    16 Jun 2011
    Link to this post
    Hello,

    I am not sure about the fix you implemented, since this code is resolve on the server, before you modify it on the client.
    We made some changes to the code base and you can open a support request where I will attach a custom build that you can use.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested 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
14 posts, 1 answered