This small utility will guide you to construct a full URL from a given site name and query string collection.
Just pass the site URL without Query string and query string collection in name value format and this method will construct a full URL. It loop through each and every query string in name value collection and construct the URL.
public string GetPageUrlWithQueryString(string SiteURL, NameValueCollection
collectionOfQueryStrings)
{
try
{
mtAdmin = new MTAdmin();
string url = mtAdmin.GetPageUrl(pageId);
string queryString = "";
for (int i = 0; i < collectionOfQueryStrings.Count; i++)
{
queryString = queryString + collectionOfQueryStrings.GetKey(i) + "=" +
collectionOfQueryStrings.Get(i) + "&";
}
queryString = queryString.Substring(0, queryString.Length - 1);
return (url + "?" + queryString);
}
catch (Exception ex)
{
throw ex;
}
finally
{
}
}
0 comments:
Post a Comment