can a forms action url contain querystring values? [duplicate]
can a forms action url contain querystring values?
Yes
it can.
But
when method="get"
then the querystring will be stripped out and replaced by the form input names/values (since the form controls are those that build the GET
querystring).
<form method="get" action="?param=foo">
<input type="hidden" name="param" value="bar" />
</form>
will submit param=bar
To keep the value you should specify method="post"
on the form
.
<form method="post" action="?param=foo">
<input type="hidden" name="otherparam" value="bar" />
</form>
will submit param=foo&otherparam=bar
<form method="post" action="?param=foo">
<input type="hidden" name="param" value="bar" />
</form>
will submit param=foo¶m=bar
(so, depending on how you process the request, you could get either an array value or unexpected results).
Yes, it can.
(Keystrokes)
I've just checked using a reduced test case:
- Form.htm that contains a form with an
action
ofdefault.aspx?query=1
and a submit button. - default.aspx that contains code in
Page_Load
to write outRequest.QueryString["query"]
The result I got when clicking on the button was a page that read:
1
So, the answer is yes.
精彩评论