code_junkie

Question regarding an ASP.NET MVC form posting scenario

Nov 12th, 2011
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <%
  2. using (Html.BeginForm())
  3. {
  4. %>
  5. <table>
  6. <tr>
  7. <td>Street Address</td>
  8. <td>
  9. <%= Html.TextBox("StreetAddress", (ViewData.Model != null) ? ViewData.Model.StreetAddress : "") %>
  10. <%= Html.ValidationMessage("Address.StreetAddress") %>
  11. </td>
  12. </tr>
  13. </table>
  14. <%= Html.SubmitButton() %>
  15. <%
  16. if (ViewData["GeocodeResults"] != null) {
  17. %>
  18. <p>
  19. Google maps found the following addresses that matched the address you entered. Please select
  20. the appropriate address. If none of these addresses are correct, try reentering the address
  21. again and be as specific as possible.
  22. </p>
  23. <ul>
  24. <%
  25. foreach (GeocodeResult geocodeResult in (List<GeocodeResult>)ViewData["GeocodeResults"]) {
  26. %>
  27. <li>
  28. <%= geocodeResult.StreetAddress %>
  29. </li>
  30. <%
  31. }
  32. %>
  33. </ul>
  34. <%
  35. }
  36. %>
  37. <%
  38. }
  39. %>
  40.  
  41. <a href='javascript:void(0);' onclick='submitAddress(this);'>
  42. <%= geocodeResult.StreetAddress %></a>
  43.  
  44. function submitAddress(link) {
  45. $('input#streetAddress:first').text(link.innerHtml);
  46. $('input#submit').click();
  47. }
Add Comment
Please, Sign In to add comment