I have some checkboxes with a unique id. is it possible to find all the checkbox+uniquenum in a form collection?
something like -
foreach (var item in Collection.Request.Form["checkbox" + with UniqueIDNum])
{
//code
}
There are several different ways you can loop on the elements of a collection. However, the recommended method for looping on a collection is to use the For Each... Next loop. In this structure, Visual Basic repeats a block of statements for each object in a collection.
The Form collection retrieves the values of form elements posted to the HTTP request body, with a form using the POST method. Form input is contained in headers. It is wise to not trust the data that is contained in headers, as this information can be falsified by malicious users.
No.
Instead, you can loop through all of the keys, and check whether they start with checkbox
.
For example:
foreach(string key in Request.Form) {
if (!key.StartsWith("checkbox")) continue;
...
}
The NameValueCollection enumerator returns keys as strings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With