访问C#处理程序中隐藏的HTML字段 [英] Access hidden HTML field in C# handler

查看:136
本文介绍了访问C#处理程序中隐藏的HTML字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<form action="FileUploadHandler.ashx" method="post">
        <input type="hidden" name="pp" id="pp" value="root" runat="server" />
    </form>

我有这个HTML代码,我需要访问我的处理程序中隐藏的元素



我尝试过:



i试过这个但是总是返回空值



i have this html code and i need to access the hidden element in my handler

What I have tried:

i have tried this but return null value always

NameValueCollection nvc = content.Request.Form;

                        string name = nvc["pp"];

推荐答案

您的意思是上下文而不是内容吗?



Did you mean context rather than content?

NameValueCollection nvc = context.Request.Form;


你的< input> runat =server,但您的< form> 没有。



您的页面将返回一个异常,指示控件必须放在带有的表单标签内RUNAT = 服务器;或者您显示的< form> 标记嵌套在现有服务器表单中。



嵌套表单无效或受支持。他们的行为是不明确的;他们可能排序在某些浏览器中工作,但这可能会随时更改。



Your <input> has runat="server", but your <form> does not.

Either your page will return an exception indicating that the control must be placed inside a form tag with runat="server"; or the <form> tag you've shown is nested inside an existing server form.

Nested forms are not valid or supported. Their behaviour is undefined; they might sort-of work in some browsers, but that is subject to change at any time.

注意:严禁将表单嵌套在另一个表单中。嵌套可能导致表单根据正在使用的浏览器以不可预测的方式运行。

Note: It's strictly forbidden to nest a form inside another form. Nesting can cause forms to behave in an unpredictable manner based on the browser that is being used.


这篇关于访问C#处理程序中隐藏的HTML字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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