HttpRequest.Form プロパティ
フォーム変数のコレクションを取得します。
Public ReadOnly Property Form As NameValueCollection
[C#]
public NameValueCollection Form {get;}
[C++]
public: __property NameValueCollection* get_Form();
[JScript]
public function get Form() : NameValueCollection;
プロパティ値
フォーム変数のコレクションを表す NameValueCollection 。
解説
HTTP 要求で使用する Content-Type が application/x-www-form-urlencoded
または multipart/form-data
の場合に限り取得されます。
使用例
クライアントのフォーム コレクションを取り込み、各フォームの名前を HTTP 出力へ書き込む例を次に示します。
Dim loop1 As Integer
Dim arr1() As String
Dim coll As NameValueCollection
' Load Form variables into NameValueCollection variable.
coll=Request.Form
' Get names of all forms into a string array.
arr1 = coll.AllKeys
For loop1 = 0 To arr1.GetUpperBound(0)
Response.Write("Form: " & arr1(loop1) & "<br>")
Next loop1
[C#]
int loop1;
NameValueCollection coll;
//Load Form variables into NameValueCollection variable.
coll=Request.Form;
// Get names of all forms into a string array.
String[] arr1 = coll.AllKeys;
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{
Response.Write("Form: " + arr1[loop1] + "<br>");
}
[C++]
int loop1;
NameValueCollection* coll;
//Load Form variables into NameValueCollection variable.
coll=Request->Form;
// Get names of all forms into a string array.
String* arr1[] = coll->AllKeys;
for (loop1 = 0; loop1 < arr1->Length; loop1++)
{
Response->Write(String::Format(S"Form: {0}<br>", arr1[loop1]));
}
[JScript]
var arr1 : String[]
var coll : NameValueCollection
coll=Request.Form // Load Form variables into NameValueCollection variable.
arr1 = coll.AllKeys // Get names of all forms into a string array.
for(var i=0; i < arr1.Length; i++){
Response.Write("Form: " + arr1[i] + "<br>")
}
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ