Why does System.Web.UI.WebControls.HiddenField
inherit System.Web.UI.Control
instead of System.Web.UI.WebControls.WebControl
? It seems really illogical placement if not the fact that hidden fields are used in web pages.. What's the reason it was designed like this?
It makes things quite annoying when you can't do things like WebControl x = new HiddenField();
A hidden field lets web developers include data that cannot be seen or modified by users when a form is submitted. A hidden field often stores what database record that needs to be updated when the form is submitted.
The HiddenField control is used to store a value that needs to be persisted across posts to the server. It is rendered as an <input type= "hidden"/> element. Normally view state, session state, and cookies are used to maintain the state of a Web Forms page.
The primary difference between UI.Control
and UI.WebControls.WebControl
is that WebControl
is meant to serve as a base class for a component that has a UI. Since a hidden field never displays anything to the user (it's hidden, after all), UI.Control
is a more suitable base class.
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