AI OnAI Off
using System;
using System.Collections.Specialized;
using System.Text;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.Util;
namespace KnowIT.WebControls
{
///
///
///
public class FriendlyUrlRegistration : EPiServer.WebControls.FriendlyUrlRegistration
{
private IPageSource _iPageSource;
protected IPageSource PageSource()
{
if (this._iPageSource == null)
{
this._iPageSource = this.Page as IPageSource;
if (this._iPageSource == null)
{
throw new EPiServerException("This control must be placed on a page that implements IPageSource");
}
}
return this._iPageSource;
}
protected override void Render(System.Web.UI.HtmlTextWriter writer)
{
if((bool) Global.EPConfig["EPfEnableFriendlyURL"])
{
writer.Write(this.Framework());
this.ClientScript();
}
}
protected void ClientScript()
{
if(FriendlyUrlModule.IsCurrentRequestFriendly)
{
string url = this.PageSource().CurrentPage.LinkURL;
string extension = string.Empty;
string query = string.Empty;
if((Global.EPConfig["EPsFriendlyUrlExtension"].ToString() == "/") || (Global.EPConfig["EPsFriendlyUrlExtension"].ToString().Length == 0))
{
extension = FriendlyUrlModule.PostbackExtension;
}
if(this.Page.Request.QueryString.Count > 0)
{
NameValueCollection queries = new NameValueCollection(this.Page.Request.QueryString);
queries.Remove("id");
queries.Remove("eplanguage");
query = CreateQuery(queries).ToString();
}
this.Page.RegisterClientScriptBlock("FriendlyUrlPostBack", "");
}
}
internal static StringBuilder CreateQuery(NameValueCollection queries)
{
StringBuilder query = new StringBuilder("");
foreach(string key in queries.AllKeys)
{
if (query.Length > 1)
{
query.Append("&");
}
else
{
query.Append("?");
}
query.Append(key).Append("=").Append(queries[key]);
}
return query;
}
protected string Framework()
{
if(Environment.Version.Major < 2)
{
return ("<base href=\"" + Global.EPConfig.HostUrl + this.Page.TemplateSourceDirectory + "/\" />");
}
return string.Empty;
}
}
}
/HAXEN
Link text
When I hover over the links i get the following in the status bar: /templates/grouppage.aspx?id=229&epslanguage=EN&cs=01#colours and clicking the links has the desired effect. However when I change the id of the page on the demo siteLink text
When I hover over the link what i get in the status bar is: /en/page1/page2/ and clicking on the link sends me to the desired page but without providing the desired querystring data Any ideas would be much appreciated