Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

View

By: a guest on Feb 21st, 2013  |  syntax: HTML 5  |  size: 3.06 KB  |  views: 106  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. @using (Html.BeginForm("Register", "Account", FormMethod.Post, new {id = "registration"}))
  2. {
  3.     @Html.ValidationSummary(excludePropertyErrors: true)
  4.  
  5.     <fieldset>
  6.         <legend>Registration</legend>
  7.         <p>
  8.             @Html.LabelFor(m => m.SelectedHmc, @Resources.RegistrationHmc)
  9.             @Html.DropDownListFor(x => x.SelectedHmc, Model.HmcList)
  10.         </p>
  11.         <p>
  12.             @Html.LabelFor(m => m.SelectedCity, @Resources.RegistrationCity)
  13.             @Html.DropDownListFor(m => m.SelectedCity, Model.CityList, new {onchange = "FetchStreets();"})
  14.         </p>
  15.        
  16.         <p>
  17.             @Html.LabelFor(m => m.SelectedStreet, @Resources.RegistrationStreet)
  18.             @Html.DropDownListFor(m => m.SelectedStreet, Model.StreetList, new {onchange = "FetchHouses();", @data_bind = "options: StreetList, optionsText: 'Name', optionsValue: 'Id', optionsCaption: 'Select...'"})
  19.         </p>
  20.         <p>
  21.             @Html.LabelFor(m => m.SelectedHouse, @Resources.RegistrationHouse)
  22.             @Html.DropDownListFor(m => m.SelectedHouse, Model.HouseList, new { @data_bind="options: HouseList, optionsText: 'Number', optionsValue: 'Id'"})
  23.         </p>
  24.         <p>
  25.             @Html.LabelFor(m => m.AppartmentNumber, @Resources.RegistrationAppartmentNumber, new {@class = "registration-label-input"})
  26.             @Html.TextBoxFor(m => m.AppartmentNumber)  
  27.         </p>
  28.         <p>
  29.             @Html.LabelFor(m => m.Email, @Resources.RegistrationEmail, new {@class = "registration-label-input"})
  30.             @Html.TextBoxFor(m => m.Email)
  31.         </p>
  32.         <p>
  33.             @Html.LabelFor(m => m.PhoneNumber, @Resources.RegistrationPhoneNumber, new {@class = "registration-label-input"})
  34.             @Html.TextBoxFor(m => m.PhoneNumber)    
  35.         </p>
  36.         <p>
  37.             @Html.LabelFor(m => m.Password, @Resources.RegistrationPassword, new {@class = "registration-label-input"})
  38.             @Html.PasswordFor(m => m.Password)
  39.         </p>
  40.         <p>
  41.             @Html.LabelFor(m => m.ConfirmPassword, @Resources.RegistrationConfirmPassword, new {@class = "registration-label-input"})
  42.             @Html.PasswordFor(m => m.ConfirmPassword)
  43.         </p>
  44.         <label>&nbsp; </label>
  45.         <input type="submit" value='@Resources.RegistrationButton' />
  46.     </fieldset>
  47. }
  48.  
  49. <script type='text/javascript'>
  50.  
  51.     function CascadingDdLViewModel() {
  52.         this.StreetList = ko.observableArray([]);
  53.         this.HouseList = ko.observableArray([]);
  54.     }
  55.  
  56.     var objVM = new CascadingDdLViewModel();
  57.     ko.applyBindings(objVM);
  58.  
  59.     function FetchStreets() {
  60.         objVM.HouseList([]);
  61.         objVM.StreetList([]);
  62.         var cityCode = $("#SelectedCity").val();
  63.         $.getJSON("/Account/GetStreets/" + cityCode, null, function(data) {
  64.             objVM.StreetList(data);
  65.         });
  66.        
  67.     }
  68.  
  69.     function FetchHouses() {
  70.         var streetCode = $("#SelectedStreet").val();
  71.         $.getJSON("/Account/GetHouses/" + streetCode, null, function(data) {
  72.             objVM.HouseList(data);
  73.         });
  74.     }
  75.  
  76. </script>