private void Page_Load(object sender, EventArgs e)
		{
			XmlDocument configDoc = new XmlDocument();
			configDoc.Load(Server.MapPath(Configuration.ConfigFile));
			Configuration configuration = new Configuration(configDoc);
			treeNavigator.ContentFile = configuration.ExamplesDataFile;
		}
Example #2
0
		private string GetDefaultExampleUrl(string controlName)
		{
			//open quickstart config to find the examples file
			System.Xml.XmlDocument configDoc = new XmlDocument();
			configDoc.Load(Server.MapPath(Configuration.ConfigFile));
			Configuration configuration = new Configuration(configDoc);

			//open the examples file and try to find the control's branch
			System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
			xmlDoc.Load(Server.MapPath(configuration.ExamplesDataFile));
			System.Xml.XmlNode controlNode = xmlDoc.DocumentElement.SelectSingleNode(string.Format("/examples/category[translate(@text, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='rad{0}']", controlName));
			if (Object.Equals(controlNode,null))
			{
				//try without the Rad prefix
				controlNode = xmlDoc.DocumentElement.SelectSingleNode(string.Format("/examples/category[translate(@text, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='{0}']", controlName));
			}
			if (Object.Equals(controlNode,null))
			{
				//if no control branch, use the root 
				controlNode = xmlDoc.DocumentElement;
			}
			
			System.Xml.XmlNode exampleNode = controlNode.SelectSingleNode("example[@default='true']");
			if (exampleNode == null)
				exampleNode = controlNode.SelectSingleNode("category/example[@default='true']");
			if (exampleNode != null)
			{
				//use lowercase for the application path! solves telerik.com site problem
				string exampleUrl = Request.ApplicationPath.ToLower();
				if (!exampleUrl.EndsWith("/")) exampleUrl += "/";
				exampleUrl += exampleNode.Attributes["name"].Value + "/Default.aspx";
				return PageUtility.LanguageSpecificUrl(exampleUrl);
			}
			else
			{
				//no default example found
				return string.Empty;
			}
		}