In ASP. NET, the following methods can be used to obtain the values of page elements in the background:
Request. Form (post), request. querystring (get), request. Params, and so on.
Of course, you can also directly use the index of the request itself.
-----
Sometimes, the values of form elements (such as the drop-down list) on our page are dynamically changed through Ajax (JS), and then used in the background. value can no longer be obtained.
What should we do at this time?
1. You can use a hidden control to store the selected values. Then obtain the value of the hidden control in the background.
2. We should know that the value passing of the form element is identified by the name attribute (whether post or get ).
No matter how the value changes, the name of the element remains unchanged. In ASP. NET, it indicates that the uniqueid is unchanged. Then we can use
Request [***. uniqueid] to obtain the element value.
------
How can we get the value if there are multiple elements with the same name on the page?
You can also obtain the request and several related (object) attributes. By default, the obtained values are separated by commas.
But what if the input value in the form element itself contains a comma?
", We seldom notice that several (object) attributes of the Request contain a pair of methods (get and getvalues ). They can actually get the passed element values.
When multiple elements with the same name exist:
Get values are separated by commas (,), regardless of whether the element value contains commas.
Getvalues stores the obtained element values in arrays instead of commas.
We can imagine that get is another layer of packaging for getvalues (array join method connection)
Therefore, if you want to obtain the values of multiple elements with the same name, you can use getvalues ..