I have a view for viewing and editing accounts. This has an "edit" button and a "save" button.
I would like the view to display the information as labels and change this to textboxes when edit is clicked. How can I change the lables to textboxes and vice versa? I currently have a javascript function to hide/show the save button when edit is clicked, presumably I can achieve the result in javascript also?
My view html is below (currently using textbox not label)
<script type="text/javascript">
function SetEditButton()
{
var editOrSave = document.getElementById("editButton").value;
if (editOrSave == "Edit") {
//AccountPopupControl.SetHeaderText(AccountPopupControl.HeaderText + " EDIT");
document.getElementById("saveButton").style = "float: right;display:block;"
document.getElementById("editButton").style = "float: right;display:none;"
}
else {
//AccountPopupControl.SetHeaderText(AccountPopupControl.HeaderText.substring(0, AccountPopupControl.HeaderText.length - 5));
document.getElementById("editButton").style = "float: right;display:block;"
document.getElementById("saveButton").style = "float: right;display:none;"
}
return editOrSave;
}
</script>
<table style="width:100%;height:100%">
<tr>
<td>
<div class="verticalLine">
<table style="width:100%;height:100%">
<tr>
<td valign="top">
<p class="big">Name:</p><br />
<p class="big">Reference:</p><br />
<p class="big">Description:</p><br />
<p class="big">Adress Line 1:</p><br />
<p class="big">Adress Line 2:</p><br />
<p class="big">Adress Line 3:</p><br />
<p class="big">Adress Line 4:</p><br />
<p class="big">Adress Line 5:</p><br />
</td>
<td valign="top">
<p class="big">@Html.TextBoxFor(model => model.name, new { id = "nameTxtBx", @readonly = "true" })</p><br />
<p class="big">@Html.TextBoxFor(model => model.reference, new { id = "referenceTxtBx", @readonly = "true" })</p><br />
<p class="big">@Html.TextBoxFor(model => model.description, new { id = "descriptionTxtBx", @readonly = "true" })</p><br />
<p class="big">@Html.TextBoxFor(model => model.address1, new { id = "address1TxtBx", @readonly = "true" })</p><br />
<p class="big">@Html.TextBoxFor(model => model.address2, new { id = "address2TxtBx", @readonly = "true" })</p><br />
<p class="big">@Html.TextBoxFor(model => model.address3, new { id = "address3TxtBx", @readonly = "true" })</p><br />
<p class="big">@Html.TextBoxFor(model => model.address4, new { id = "address4TxtBx", @readonly = "true" })</p><br />
<p class="big">@Html.TextBoxFor(model => model.address5, new { id = "address5TxtBx", @readonly = "true" })</p><br />
</td>
</tr>
</table>
</div>
</td>
<td>
<div>
<table style="width:100%;height:100%">
<tr>
<td valign="top">
<p class="big">Custom 1:</p><br />
<p class="big">Custom 2:</p><br />
</td>
<td valign="top">
<p class="big">@Html.TextBoxFor(model => model.custom1)</p><br />
<p class="big">@Html.TextBoxFor(model => model.custom2)</p><br />
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>