我在ASPX页面上有一个get/post/json函数。此页将在文本框中输入的数据添加到由javascript填充的表中。当用户选择提交按钮时。如果文本框不是空的,则弹出一个按钮,告诉用户文本框中的数据没有保存在表中。如何在控制器中的Post操作上显示确认“确定/取消”弹出窗口?
我快速总结了代码的外观。
...
<% using (Html.BeginForm("AddName", "Name", FormMethod.Post, new { id = "AddNameForm" })) { %>
...
<table id="displayNameTable" width= "100%">
<tr>
<th colspan="3">Names Already Added</th>
</tr>
<tr>
<td style="font-size:smaller;" class="name"></td>
</tr>
</table>
...
<input name="Name" id="txtInjuryName" type="text" value="<%=test.Name %>" />
...
<input type="submit" name="add" value="Add"/>
<% } %>
<form id="form1" runat="server">
string confirmNext = "";
if (test.Name == "")
{
confirmNext = "return confirm('It seems you have a name not added.\n\nAre Continue?')";
}%>
<input type="submit" name="getNext" value="Next" onclick="<%=confirmNext%>" />
</form>