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

Forums / Developing with Sitefinity / Problem with hardcoded main navigation

Problem with hardcoded main navigation

15 posts, 2 answered
  1. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    09 Jun 2010
    Link to this post
    Hello Telerik Team!

    We have decided to hardcode the main navigation of our site instead of using the available control because we felt it was easier to do.

    So for sample's sake the Master page looks like this:

    <div class="mainnav">
    <ul>
    <li><a href="home.aspx">Home</a></li>
    <li><a href="about/about.aspx">About Us</a></li>
    <li><a href="about/contact.aspx">Contact Us</a></li>
    </ul>
    </div>

    And then the navigation menu would be rendered perfectly. But how come with the current setup of things this scenario occurs:

    1. While on Home page (url: http://server/home.aspx) , I decide to proceed to About Us page (Menu item url: http://server/about/about.aspx)
    2. From About Us page, I decide to go back to Home page but then something wrong happens to the home page's menu item url! (Menu item url: http://server/about/home.aspx) The About section as you can see contains subpages. But I wonder why the url's got jumbled up.

    Am I missing something? Thank you very much for you usual support. :)
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    09 Jun 2010
    Link to this post
    Hello jkregala,

    Could you try using this method for the hard coded navigation:
    <a href="<%=Telerik.Cms.Web.UrlHelper.ResolveUrl("~/home.aspx") %>">page</a>
     

    Currently on your different level of pages since you are not using rooted paths the website is looking for the home page on the same level as the about us page which is going to give 404 because the path is not correct. The above approach is the recommended one if you are going to build hard coded navigation as yours.

    Greetings,
    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.
  3. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    09 Jun 2010
    Link to this post
    Negative Sir Radoslav.

    Using the same scenario aforementioned, the URL is now http://server/about/~/home.aspx
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    09 Jun 2010
    Link to this post
    Hi jkregala,

    Try without ~/.

    Greetings,
    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.
  5. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    09 Jun 2010
    Link to this post
    Tried that one too. It has no effect. The problem persists.
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    09 Jun 2010
    Link to this post
    Hello jkregala,

    I am sorry the last one was a typo. This should work:
    <a href="<%=Telerik.Cms.Web.UrlHelper.ResolveUrl("/home.aspx") %>">home</a>

    Kind 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
  7. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    09 Jun 2010
    Link to this post
    Problem solved! Thank you so much once again. :)
  8. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    09 Jun 2010
    Link to this post
    Sir Radoslav, something's wrong. :(
    Everytime I try to access the pages containing the hardcoded navigation in Edit mode, this error occurs:

    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
    System.Web.UI.ControlCollection.AddAt(Int32 index, Control child) +8668018
    Telerik.Cms.Web.EditPage.CreateChildControls() +267
    System.Web.UI.Control.EnsureChildControls() +87
    System.Web.UI.Control.PreRenderRecursiveInternal() +44
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
  9. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    09 Jun 2010
    Link to this post
    Hi jkregala,

    Substitute the = character with #:
    <a href="<%#Telerik.Cms.Web.UrlHelper.ResolveUrl("/home.aspx") %>">home</a>


    Best wishes,
    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
  10. jkregala
    jkregala avatar
    159 posts
    Registered:
    22 Sep 2009
    09 Jun 2010
    Link to this post
    That worked! Thanks once again. :)
  11. Kelly
    Kelly avatar
    24 posts
    Registered:
    05 May 2010
    28 Jun 2010
    Link to this post
    This was very helpful, I had the same problem with the edit mode, I changed the = to #, which fixed the edit problem. But now if you click the link it is giving me a 404 error. Any suggestions?
  12. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    29 Jun 2010
    Link to this post
    Hello Kelly Andreae,

    Could you make sure that the Url you want to resolve is correct?

    Greetings,
    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
  13. Kelly
    Kelly avatar
    24 posts
    Registered:
    05 May 2010
    29 Jun 2010
    Link to this post
    The url is correct, because it works with the =. When I have the = sign I get the editing error, but when I changed it to # it I got the 404.

    <a href="<%#Telerik.Cms.Web.UrlHelper.ResolveUrl ("/index.aspx") %>">Home</a>
  14. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    29 Jun 2010
    Link to this post
    Hi Kelly Andreae,

    And what is the path that you are getting 404 for? I mean to what path does it resolve the url? Can you try without the forward slash in front of index.aspx?

    All the best,
    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
  15. Kelly
    Kelly avatar
    24 posts
    Registered:
    05 May 2010
    29 Jun 2010
    Link to this post
    Removing the forward slash did not help. It is resolving as http://server/about/.
Register for webinar
15 posts, 2 answered