I currently have a user control that is used on both an /Address/Edit and an /Address/Create page. This user control simply has the following code in it to submit a new address to the system:
<%
using (Html.BeginForm())
{
%>
<table>
<tr>
<td>Street Address</td>
<td>
<%= Html.TextBox("StreetAddress", (ViewData.Model != null) ? ViewData.Model.StreetAddress : "") %>
<%= Html.ValidationMessage("Address.StreetAddress") %>
</td>
</tr>
</table>
<%= Html.SubmitButton() %>
<%
if (ViewData["GeocodeResults"] != null) {
%>
<p>
Google maps found the following addresses that matched the address you entered. Please select
the appropriate address. If none of these addresses are correct, try reentering the address
again and be as specific as possible.
</p>
<ul>
<%
foreach (GeocodeResult geocodeResult in (List<GeocodeResult>)ViewData["GeocodeResults"]) {
%>
<li>
<%= geocodeResult.StreetAddress %>
</li>
<%
}
%>
</ul>
<%
}
%>
<%
}
%>
To summarize the code above, what it does is in the controller, it queries Google Maps to geocode the address in the text box (i.e. turns it into a set of longitude/latitude coordinates). When Google Maps returns more than one result, I store off these results into ViewData["GeocodeResults"], which will then display the possible addresses to the end user.
Now, this is working fine for displaying the addresses, but what I really want is that list to be rendered as a list of hyperlinks so that the user can click on the appropriate address and the form will submit with that address instead of the one in the textbox. Is there any way to do this?