Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HiddenField isn't a WebControl?

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();

like image 284
Izzy Avatar asked Apr 16 '13 15:04

Izzy


People also ask

What is a 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.

Why we use hidden fields In ASP net?

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.


1 Answers

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.

like image 88
Nate Dudek Avatar answered Sep 30 '22 16:09

Nate Dudek