【发布时间】:2025-12-17 16:55:02
【问题描述】:
我在一个 aspx 页面上有一个 get/post/JSON 函数。此页面将在文本框中输入的数据添加到由 javascript 填充的表中。当用户选择提交按钮时。如果文本框不为空,则有一个弹出按钮告诉用户文本框中的数据未保存在表格中。如何在控制器中的发布操作上显示确认“确定/取消”弹出窗口? 我快速总结了我的代码是什么样的。
...
<% 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>
【问题讨论】:
标签: html asp.net-mvc model-view-controller asp.net-mvc-2