I have an XML file with several environment names and corresponding URL to the environment name. Requirement is: 1. display the environment names in a dropdownlist 2. select any environment name in dropdownlist. 3. Click Navigate link below dropdown button. 4. The page should be navigated to particular URL, which the environment name belongs to.
EX: (from XML File)
I want to fetch "name" & "LMHost" .
I completed upto creating dropdownlist. Binding environment name inside dropdownlist. But i dunno how to navigate it to particular URL.
My Controller Code
var xDoc = XDocument.Load(fileName);
IEnumerable<XElement> envGroups = from xmlDoc in xDoc.Descendants().Elements("environment")
select xmlDoc;
model.EnvironmentName = from envName in envGroups.Attributes("name")
select new SelectListItem
{
Text = envName.Value,
Value = envName.Value.ToString(),
Selected = (envName.Equals(envName))
};
return View(model);
View Code
<%=Html.DropDownList("EnvironmentName", new SelectList (Model.EnvironmentName, "Value" , "Text")) %>
Model Code
public IEnumerable _environmentName;
[DisplayName("EnvironmentName")]
public IEnumerable<SelectListItem> EnvironmentName
{
get
{
if (_environmentName == null)
_environmentName = new List<SelectListItem>();
return _environmentName;
}
set { _environmentName = value; }
}
Kindly help me. I find difficult to navigate the environment names to its particular URL