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

Assigning an absolute url to menu item's navigate url

2 Answers 283 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Riley Griffin
Top achievements
Rank 1
Riley Griffin asked on 25 Jun 2009, 09:29 PM
Good Afternoon.

I realize there are a large number of threads on similar topics. However, none of the solutions I was able to find have worked.

I am given a list of structs from a function that accesses a database. The structs hold the absolute url path to a web site (potentially to an external site) and the desired text value of the link.  I use the information in this list to construct a string that holds the xml needed to render the rad menu control.  I do this so I can store the string as a session variable so I only need to access the database once.  I then bind the menu to the string:

                string linkMenuXML = Session["quicklinkXML"].ToString();
                LinksMenu.LoadXml(linkMenuXML);

The menu builds just fine but the urls are all relative. 

                 example: NavigateUrl = "www.telerik.com" but the href="http://localhost:5011/www.telerik.com"

I tried using the HrefBaseDir property with no luck.  Am I missing something?  The threads that give the HrefBaseDir property as a solution are all 3 years old or older from what I found.  Is there an updated propery I should use?  The following is an example fuction that builds the linkMenuXML string:



private string getLinksXmlString()
        {
            List<Links> LinksList = new List<Links>();
            string xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><Menu EnableEmbeddedSkins=\"false\" HrefBaseDir=\"\" Skin=\"NavBarSkin\" EnableScreenBoundaryDetection=\"false\"><Group><Item Text=\"Links\"><Group Flow=\"Vertical\">";

            //putting stuff in the list
            for (int i = 0; i < 10; i++)
            {
                Links temp = new Links();
                temp.Name = "Link Number " + i.ToString();
                temp.NavigateUrl = "www.telerik.com";
                LinksList.Add(temp);
            }

            foreach (Link link in LinksList)
            {
                xmlString += "<Item Text=\"" + link.Name + "\" HrefBaseDir=\"\" NavigateUrl=\"" + link.NavigateUrl + "\"></Item>";
            }

            xmlString += "</Group></Item></Group></Menu>";

            return xmlString;

        }

Thank you in advance for any help you can provide!

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 26 Jun 2009, 08:28 AM
Hi Riley Griffin,

You need to specify the protocol

item.NavigateUrl = "http://www.example.com";

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Riley Griffin
Top achievements
Rank 1
answered on 26 Jun 2009, 01:21 PM
Thanks Albert!!

Sure enough that did the trick.  I'm a little embarrassed I wasn't able to notice the pattern.  I just need to do a string verification on the url strings to make sure they start with "http://" "https://" "ftp://" or "ftps://"

Thanks again on your quick responce!
Tags
Menu
Asked by
Riley Griffin
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Riley Griffin
Top achievements
Rank 1
Share this question
or