ASP.net C#无法读取发布的表单元素 [英] ASP.net C# can't read posted form element

查看:104
本文介绍了ASP.net C#无法读取发布的表单元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的母版页上,我有:

On my master page I have:

<form id="ReportForm" action="HelpAsk.aspx" method="post">
    <input type="hidden" id="HiddenReport" type="text" />
</form>

这是位于标记之前的任何服务器标记之外。

This is outside any server tags, just before the tag.

Jquery在页面上点击某个按钮时提交此表单:

Jquery submits this form when a button on the page is clicked somewhere:

function SendReport() {
    $("#HiddenReport").val("<html>" + $("html").html() + "</html>");
    $('#ReportForm').submit();    
}

但无论我尝试什么,我都无法让我的收件网页读取data:

But whatever I try, I can't get my receiving page to read that data:

NameValueCollection nvc = Request.Form;
if (!string.IsNullOrEmpty(nvc["HiddenReport"]))
{
    Response.Write("LOL:" + Request.Form["HiddenReport"]);
}


推荐答案

您需要输入元素的名称属性,使它与表单一起发布提交,例如

You need to give the input element a name attribute to have it posted with the form submit, e.g.

<input type="hidden" id="HiddenReport" name="HiddenReport" />

您还有两个类型属性,删除其中一个。

Also you have two type attributes, remove one of these.

这篇关于ASP.net C#无法读取发布的表单元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆