Learning how to work with ASP.NET Web Forms is the other thing of ‚ÄúNew Things Learned in the Labor Camp‚ÄĚ‚Ä¶ I‚Äôve avoided confronting ASP.NET ‚Äúclassic‚ÄĚ directly for years. Instead, I made the right decision to learn things about Web programming and Web design that Microsoft notoriously undervalued in its professional communication for years until the rise of Scott Guthrie from ASP.NET ‚Äúclassic‚ÄĚ to ASP.NET MVC.
Sadly, there is a job market full of IT shops that are deeply invested (often emotionally invested) in ASP.NET ‚Äú1.9‚ÄĚ‚ÄĒthe way of seeing the Web through the Microsoft looking glass just before ASP.NET 2.0 was released in 2005.
For years I‚Äôve ‚Äúrun away‚ÄĚ from confronting ASP.NET Web Forms directly. The following interview questions I‚Äôve slapped together ‚Äúfinally‚ÄĚ engage‚ÄĒdirectly. By the way to show that I‚Äôm super serious about this matter, I‚Äôve literally spent hours over about two weeks building samples for ASP.NET for Web Forms in my studio.
What are ASP.NET Web Forms?
ASP.NET Web Forms is a technology that breaks down a plain-old HTTP Request into a series of clearly defined events (classified broadly under initialization, load and render)‚ÄĒthese events describe the ‚Äúlife cycle‚ÄĚ of a familiar model, the data-entry form in a Web page. ASP.NET is based on the event-driven programming paradigm made popular and traditional by Microsoft in the 1990s.
What is a ‚ÄėPost Back‚Äô?
The ‚ÄėPost Back‚Äô is the concept developed by Microsoft that stands between the post HTTP verb and the first event recognized by an ASP.NET
Page. Typically, the
Page.IsPostBack Boolean is checked in the
Page.OnLoad event handler. When
Page.IsPostBack == false then the get HTTP verb is the request. Microsoft has defined a conventional Jscript function,
__doPostBack(), that invokes the ‚ÄėPost Back.‚Äô ASP.NET Web Forms seem crude and extravagant in the 21st century when a page-level post action is regarded as expensive and disruptive (ASP.NET AJAX was supposed to remedy this).
Why do ASP.NET controls require a parent form?
Without a parent
form element, the ‚ÄėPost Back‚Äô concept is not implemented. Conventional hidden fields in the form store event metadata (
See also: ‚ÄúTRULY Understanding ViewState‚ÄĚ
What is the AutoPostBack property?
AutoPostBack property is a Boolean that is apparently defined independently and conventionally in the
AutoPostBack == true an event associated with these controls (select, check, blur) will cause a Post Back.
What is a Cross-Page Post Back?
By default, an ASP.NET page ‚Äúposts back‚ÄĚ to itself (frequently). A Cross-Page Post Back declares that one Web Form should post to another Web Form‚ÄĒnot back to itself. Input captured in the posting page can be captured in the receiving page via the
Page.IsCrossPagePostBack property is always
null. During a cross page Post Back
Page.PreviousPage.IsCrossPagePostBack will be
What is a Server Transfer?
An ASP.NET Server Transfer allows a
Page executing on the Server to Transfer execution to another
Page. It can be thought of as a call to another procedure from the currently executing procedure. In terms of a POCO class, a Server Transfer is a method call in a procedure of one class with a member from another class‚ÄĒthe catch is that no arguments can be passed in the method call. After a Server Transfer, the new page running has access to all of the Request, Session and Application-scope data in the old page. Importantly, there is a
Page.PreviousPage property which can be used with
FindControl() to locate controls on the old page.
According to Microsoft MVP Karl Moore, ‚ÄúSo, in brief:
Response.Redirect simply tells the browser to visit another page.
Server.Transfer helps reduce server requests, keeps the URL the same and, with a little bug-bashing, allows you to transfer the query string and form variables. ‚Ä¶Don‚Äôt confuse
Server.Execute, which executes the page and returns the results. It was useful in the past, but, with ASP.NET, it‚Äôs been replaced with fresher methods of development. Ignore it.‚ÄĚ
See also: ‚ÄúASP.NET Server.Transfer Method‚ÄĚ
What is a Master Page?
The ASP.NET Master helps keep Web Forms DRY. They share visual elements among several ASP.NET pages providing the ‚Äúconsistent look and feel‚ÄĚ Web designers expect. ASP.NET Master pages also centralize HTML page ‚Äúmeta‚ÄĚ information, much of the angle-bracketed ceremony that make Web page markup noisy.
How does a Master Page affect the Control.FindControl function?
The ASP.NET Master adds one or more
ContentPlaceHolder controls to the visual tree. These in turn demand
Content controls, which implement
INamingContainer‚ÄĒa ‚Äúnaming container‚ÄĚ affects the ID attributes of child controls ‚Äúinside‚ÄĚ the container. So: a control named
foo inside a naming container,
bar, can be located by
Control would be an instance of the Master page in our example.
How do Web Forms handle Validation?
ASP.NET handles Validation with PostBack-dependent server controls. These server controls share a
ControlToValidate property, pointing to the input-related server control to Validate. There are validation controls for marking input as required, checking input for a data type, testing input with a Regular Expression and testing input with custom code.
One little annoyance: custom validators don‚Äôt work with blank input‚ÄĒso they must be paired with the validation control for marking input as required (
What are Validation groups?
Validation groups allow more than one ‚Äúvalidation context‚ÄĚ to exist in a Web Form. For example, a layout with a
GridView might have an
EditItemTemplate with one Validation Group for editing while another form used for inserting new rows into the grid will have another Validation Group. Validation groups are declared with the
What is a ‚ÄúPartial Page Update‚ÄĚ?
The ‚ÄúPartial Page Update‚ÄĚ is made possible with the
UpdatePanel and the
ScriptManager, which is the heart of ASP.NET AJAX. This extension to ASP.NET introduced in version 2.0 dramatically reduces the need to do the ‚Äúclassic‚ÄĚ PostBack by implementing the ‚Äúasynchronous PostBack‚ÄĚ a.k.a. the ‚ÄúPartial Page Update.‚ÄĚ