I am learning ASP MVC and I try do form, and when you click the button on the form, I want to add some content to div in this form.
@using (Html.BeginForm())
{
<div>
<input type="button" value="Click to edit address" onclick="@String.Format("addAddress()")" />
<div id='divResult'>
Here I want to add new conntent after click button.
</div>
<div>
}
My Java Script function does't work:
<script type="text/javascript">
function addAddress() {
$('#divResult').replaceWith("@Html.EditorFor(m => m.User.HomeAddress)");
}
</script>
Can anyone help me? I want to fill my User (model.User) object and post filled to server, but Athe address you can fill only after click button, because it has a lot of field to be filled, but address is not necessary.
Html.Raw:@Html.Raw(Html.EditorFor(...)).