Request.Form[MyControl.ClientID] is Null
I've noticed that, during a postback, Request.Form[MyControl.ClientID]
is null
. However, Request.Form[MyControl.Name]
contains the expected value.
This is unexpected. Is this d开发者_高级运维ocumented somewhere?
This is correct - browser will use control's name (and not ID) for posting the values. Further, use Request.Form[MyControl.UniqueID]
to get the value from POST data (because ASP.NET uses that value as control name in the generated html while ClientID is used as html id).
See W3C documentation that describes the form submission - check 17.13.2 & 17.13.3.
精彩评论