我在 asp.net 页面中有一个带有 Method attribute="post" 和 on Codebehinde 的小表单,我想访问这样的表单值: string val = Request.form["field"]; 但是当我放置断点并检查时,它返回空值。但我已将值放入输入文本框中并按下提交按钮。我不明白为什么它返回null。任何人都可以解释什么是问题。
问问题
2027 次
2 回答
0
You are are using runat="server"
on the textbox so the name of it in the Form collection will be probably be something like "ctl00_srchtxtx".
Make the <input>
into <asp:TextBox>
and use string val = srchtxtx.Text;
instead.
You should also add runat="server"
to your form, or you will probably get other issues.
Or if this cannot be a server form remove runat="server" from the <input>
.
于 2013-01-12T19:49:28.657 回答
0
假设 runat = "server" 为:
字符串 val = Request.Form[srchtxtx.UniqueID];
于 2013-01-13T18:04:07.517 回答