INFO: Handling Arrays of HTML Input Elements with Request.Form and Request.QueryString (312558)
The information in this article applies to:
- Microsoft ASP.NET (included with the .NET Framework 1.1)
- Microsoft ASP.NET (included with the .NET Framework) 1.0
This article was previously published under Q312558 SUMMARY
A Hypertext Markup Lanugage (HTML) form may include several input fields that share the same name. If you use the Request.Form or Request.QueryString collection to access a field name, a string is returned that contains all values from all of the fields with the given field name, which are separated by a comma (,).
To access individual values, you can use the GetValues method to obtain an array of strings. You can then use the array elements to provide access to individual values. For example, in Microsoft Visual C# .NET, use the following code:
String[] tempArray;
tempArray = Request.Form.GetValues("fieldName");
Response.Write (tempArray[0]); //Print the first value.
In Microsoft Visual Basic .NET, use the following code:
Dim tempArray() as String
tempArray = Request.Form.GetValues("fieldName")
Response.Write (tempArray(0)) 'Print the first value.
REFERENCESFor additional information about ASP.NET features, click the article number below
to view the article in the Microsoft Knowledge Base:
Modification Type: | Major | Last Reviewed: | 1/19/2004 |
---|
Keywords: | kbhtml kbinfo KB312558 |
---|
|