[ Pobierz całość w formacie PDF ]
.Since scripting in ASP is available only to late -bound languages such as VBScript and JavaScript,type -safety is not an option.In addition, server-side scripts in ASP pages get reinterpreted each timethe page is accessed, which is not ideal for performance.Form -state maintenance in an ASP-based application is also labor intensive developers must doeverything manually, including reposting data , using hidden fields, and session variables.At times,web applications are configured to run in web farm environments where there is more than one webserver available to the client.Maintaining session states becomes much harder in these scenariobecaus e it is not guaranteed that the client would return to the same server for the next request.Basically, the developers have to save states manually to SQL Server or other external storage.While ASP is a great technology to build dynamic web pages, it has room for improvement.ASP.NETevolved from ASP and overcomes most, if not all, of its shortfalls.7.2 ASP.NETVisual Basic developers have long enjoyed the ease of programming with forms and controls.Writinga VB form-based application is as simple as dragging some controls onto a form and writing some149 event-handling functions.This is one of the reasons VB has attracted lots of programmers interestedin speed of development.Microsoft wisely built this feature into ASP.NET.ASP.NET simplifies web page development with form-based programming.In ASP.NET, these formsare called Web Forms and are analogous to VB forms, replacing ASP pages.Similar to VB, WebForms programming is also event based.We don't have to write in-line ASP scripts and rely on thetop-down parsing interpretation as in ASP programming.To match the rich set of ActiveX controls thatVB programmers love in their toolset, ASP.NET equips ASP programmers with server controls.Tofurther enhance the productivity of developers, ASP.NET's Web Forms also allow for the separation ofthe application logic and the presentation layer.ASP.NET evolves from the ASP programming model with the following additional benefits:" Clean separation between the application logic (server-side code) and the pres entation layer(HTML markup)  no more spaghetti code" A rich set of server controls that automatically render HTML suitable for any clients and thatadditionally manage their states" Enhanced session-state management" An event-based programming model on the server side, which is simpler and more intuitive" Application logic that can be written in any Microsoft.NET language (VB, C#, Managed C++,etc.); application server-side code is compiled for better performance" Visual Studio.NET as a RAD tool, which simplifies the development process of Web Forms7.3 The System.Web.UI NamespaceBefore getting straight into developing your favorite Hello, World! application in ASP.NET, we feel it'simportant that you become familiar with the underlying structure of ASP.NET.This section describessome of the most important classes packaged in the System.Web.UI namespace in the ASP.NETframework.The System.Web.UI namespace defines classes and interfaces used in constructing and renderingelements on a Web Form.The most i mportant class in the System.Web.UI is the Control class, whichdefines properties, methods, and events that are common in all server controls in the Web Formsframework.Another important class in this namespace is Page, which is a derivative of the Controlclass.All ASP.NET web pages are instances of derivatives of the Page class.To have an extensibleframework, the System.Web.UI namespace also includes the UserControl class, which is similar to thePage class except that it is mainly used as the base class for user controls.We will make use of theUserControl and Page classes in "Custom Server Controls" and "ASP.NET Application Development"later in this chapter.7.3.1 Control ClassThe Control class is the root of all controls.For example, a text box is a control; a button or a combobox is also a control.The Control class basically encapsulates common functionalities and propertiesof all user-interface widgets.As you get deeper into ASP.NET development, everything you see is aControl derivative of some sort.7.3.1.1 Control's propertiesThe Control class has the following important properties: Controls, ID, Parent, EnableViewState,Visible, Context, and ViewState.We will go over each of these properties briefly to show you what theControl class is made up of and how deriving from Control class would create a model that isconsistent and easy to work with.The Controls property represents the children of the control instance; the Parent property defines theparent of the control.Together, thes e two properties enable a hierarchy of controls on a web page.The ID property allows the control to be accessed programmatically by just using the ID and the dot150 .NET Framework Essentialsnotation to get to the object's properties and methods, i.e., MyObjectId.propertyname.It als o allows usto write event handlers for events raised by this control.The EnableViewState flag indicates whether the control will maintain its view state, as well as all viewstates of its child controls.If this flag is set to true , the control will rem ember its previous view statewhen the page posts back to itself.[1] For example, if EnableViewState is set totrue, when the userperforms some operation that requires a postback, the user's previous selection or form-field data arepreserved automatically.When the page is sent back to the browser, the user can just continue fillingin the form as if he never left it.This is how all derivatives o f the Control class maintain their statesbetween requests and free developers from the plumbing works with hidden form fields.[1]Postback is the condition when an ASP page posts the data back to itself for processing.In conventional ASP programming, the stateof the fields in the form have to be managed manually.In ASP.NET, we can have these field states managed automatically with a simpleEnableViewState flag.The Context property enables us to get to information about the current HTTP request, such as theApplication, Server, Session, Request, and Response objects.ASP developers should be familiar withthese intrinsic objects [ Pobierz całość w formacie PDF ]
  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • odbijak.htw.pl