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

[Solved] LoadContentFrom URL encoding?

2 Answers 83 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Strasser
Top achievements
Rank 1
Michael Strasser asked on 11 Jan 2010, 10:31 PM
It looks like the LoadContentFrom method is encoding the URL when using more that 1 parameter (instead of encoding the parameter value(s) only).

I have a tabstrip within a ViewUserControl (that gets rendered as a PartialView).

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="System.Web.Routing" %>
<%
    Guid OrganizationId = new Guid(ViewData["OrganizationId"].ToString());
    Guid OrganizationUnitId = new Guid(ViewData["OrganizationalUnitId"].ToString());

    Response.Write("<div class=\"RowDetailsContainer\" style=\"text-align: left;\">");

    Html.Telerik().TabStrip()
        .Name("Tab" + OrganizationId.ToString())
        .Items(parent =>
            {
                parent.Add()
                    .Text("Unit Staff " + Url.Action("SummaryPersonMember", "OrganizationalUnit", new { organizationId = OrganizationId, organizationalUnitId = OrganizationUnitId }).ToString())
                    .LoadContentFrom("SummaryPersonMember", "OrganizationalUnit", new { organizationId = OrganizationId, organizationalUnitId = OrganizationUnitId })
                    ;
            }
        )
        /*.SelectedIndex(0)*/
        .Render();

    Response.Write("</div>");
%>

// Notes: OrganizationId and OrganizationUnitId are Guids.

When rendered, the url is rendered as:

http://localhost:8644/OrganizationalUnit/SummaryPersonMember?organizationId=6f898cee-9010-4a52-860c-9d0ef967d05c&amp;organizationalUnitId=2a81d7d4-bd87-4eea-8c48-30f364bb25f2






Note the &amp; between the parameters instead of the &.  If this runs, it will cause an error because the method in the controller is expecting 2 params.

I get the same problem if I use the following:

.LoadContentFrom(Url.Action("SummaryPersonMember", "OrganizationalUnit", new { organizationId = OrganizationId, organizationalUnitId = OrganizationUnitId }))

I think I have similar problems in the telerik MVC menu, which I am attempting to get to.

Thanks!
Mike



2 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 13 Jan 2010, 03:53 PM
Hello Michael,

Thank you for pointing out this issue.

In order to avoid this erroneous behavior you will need to open UI/NavigationItemLinkRenderer.cs file and replace this code snippet:
public void Start(T item, string url)
       {
           if (item.Enabled)
           {
                                            item.LinkHtmlAttributes.Merge("href",  System.Web.HttpUtility.HtmlAttributeEncode(url), false);
           }
 
           item.LinkHtmlAttributes.PrependInValue("class", " ", UIPrimitives.Link);
           writer.AddAttributes(item.LinkHtmlAttributes);
           writer.RenderBeginTag(HtmlTextWriterTag.A);
       }

with this one:
public void Start(T item, string url)
{
    if (item.Enabled)
    {
        item.LinkHtmlAttributes.Merge("href", url, false);
    }
 
    item.LinkHtmlAttributes.PrependInValue("class", " ", UIPrimitives.Link);
    writer.AddAttributes(item.LinkHtmlAttributes);
    writer.RenderBeginTag(HtmlTextWriterTag.A);
}

The fix will be included in one of the upcoming releases.

Kind regards,
Georgi Krustev
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
Michael Strasser
Top achievements
Rank 1
answered on 13 Jan 2010, 05:20 PM
This corrected the problem, thanks!
-Mike
Tags
TabStrip
Asked by
Michael Strasser
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Michael Strasser
Top achievements
Rank 1
Share this question
or