Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am creating a User Registration form in ASP.NET MVC3 using razor view engine. I am facing problem to create a dropdownlist for country. Country list come from xml file.
My project hierarchy is as follows
BusinessLayer -> User_Account -> Account_Registration.cs

This is a class library in which I want to create a Model for user registration. The code for user model is as follows
C#
public class Account_Registration
{
       public string User_Name { get; set; }
       public string User_EmailID { get; set; }
       public string User_Password { get; set; }
       public string User_RePassword { get; set; }
       public DateTime User_BirthDate { get; set; }
       public enum_Gender User_Gender { get; set; }
       public string User_Address { get; set; }
       public string User_City { get; set; }
       public string User_State { get; set; }
       public IEnumerable<SelectListItem> User_Country { get; set; }
       public string User_WebSite { get; set; }
       public string User_Description { get; set; }
}

Now I want to know that where I should put country XML file and how can I create dropdownlist for XML file.
My Xml file is as follows

HTML
<countries>
  <country code="AF" iso="4">Afghanistan</country>
  <country code="AL" iso="8">Albania</country>
  <country code="DZ" iso="12">Algeria</country>
</countries>


As I have to deploy this project on IIS so I want to know where should I put xml file so that I can access it in Account_Registration model which is in class library project and how to create dropdownlist for population countries.
Thanks
Posted
Updated 31-Mar-12 6:57am
v3
Comments
Jameel VM 19-Jun-13 0:55am    
what's the pblm? did you try anything?

1 solution

You can add the XML file in any location within your project. Just change its properties -> Copy content to Output Directory as "Copy Always". Also provide the correct path of the XML file in the code where you are reading it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900