views:

55

answers:

2

I want to format a URL to go back one directory. The code I have currently is formatting the URL like this http://localhost/contoso/place/category/florida-beach.aspx. But I want the links to be like http://localhost/contoso/category/good-beach.aspx. My current dir is http://localhost/contoso/place/ . So I need to go back one dir.

Thanks,

Here is my code.

foreach (SelectPlaceCategoriesResult category in placeCategories)
{
    placeCategoriesStr.Append("<a href=category\"); \\"
    placeCategoriesStr.Append(category.Titulo.Trim().ToLower());
    placeCategoriesStr.Append(".aspx >");
    placeCategoriesStr.Append(category.Nombre.Trim());
    placeCategoriesStr.Append("</a>, ");
}
A: 

Would this work for you?

yourUrl = String.Format("<A href=../category/{0}.aspx>{1}</a>,",category.Titulo.Trim().ToLower(),category.Nombre.Trim());
Another Programmer
A: 

I think the best way to achieve this would be the following:

foreach (SelectPlaceCategoriesResult category in placeCategories)
{
    HyperLink hypBack = new HyperLink();

    hypBack.NavigateUrl = string.Format("category/{0}.aspx", category.Titulo.Trim().ToLower());
    hypBack.Text = category.Nombre.Trim();

    Page.Controls.Add(hypBack);
}
GaryDevenay