我想在 ASP.NET C# 中使用 JS 收集动作响应。所以在 ASP.NET 按钮上单击我正在执行以下操作
ASPX 页面上的按钮
<asp:Button ID="btn_add" runat="server" CssClass="button btn-entry"
Text="Add" OnClick="btn_add_Click"
在 btn_add_Click 里面,我有
bool continue_ = isEmpty_InputForm(input_form_index);
if (!continue_)
{
Page.ClientScript.RegisterStartupScript(this.GetType(),
"onclick",
"<script type=\"text/javascript\">"
+ " var action_res = document.createElement(\"INPUT\");"
+ " action_res.type = \"hidden\";"
+ " action_res.name = \"action_res\";"
+ " action_res.value = null;"
+ " if (confirm('Are you sure?')) {"
+ " action_res.value = 'Yes';"
+ " }"
+ " document.forms[0].appendChild(action_res);"
//+ "confirm('Are you really sure?');"
+ " </script>",
false);
}
然后收集action_res我正在做的 JS var的值
string action_res = Request.Form["action_res"];
该页面为我提供了确认弹出窗口,但action_res价值始终是null!
我是 JS 新手,请有人帮我找出错误。