Presentation is loading. Please wait.

Presentation is loading. Please wait.

Www.tech.findforinfo.com1 Web Form Fundamentals Chapter-2 Unit-2.

Similar presentations


Presentation on theme: "Www.tech.findforinfo.com1 Web Form Fundamentals Chapter-2 Unit-2."— Presentation transcript:

1 www.tech.findforinfo.com1 Web Form Fundamentals Chapter-2 Unit-2

2 www.tech.findforinfo.com2 Problem with Response. Write Spaghetti code When the individual output is to be modified the entire code is to be revised Lack of flexibility Modification of the page after a month, the entire code needs to be read and later modified Confusing content and formatting Difficulty in creating larger forms

3 www.tech.findforinfo.com3 Problem with Response. Write Complexity Tracking of different types of functionalities leads to complexity

4 www.tech.findforinfo.com4 Server Controls ASP.NET provides two sets of Server Controls HTML Server Controls Contains equivalent HTML elements Use similar HTML tags Web Controls Similar to HTML controls Provide a richer object set Variety of properties and formatting

5 www.tech.findforinfo.com5 Features of HTML control They generate their own interface The properties are set and the underlying HTML tag is updated automatically when the page is rendered and sent to the client They retain their state The web pages can be created in the same way as the windows page is created

6 www.tech.findforinfo.com6 Features of HTML control They fire events You can respond to these events just like ordinary controls in windows application

7 www.tech.findforinfo.com7 The ViewState Traditional ASP A form is submitted to the server with the filled information The Server returns back with error All the information's are lost when is page is viewed by the user

8 www.tech.findforinfo.com8 The ViewState The ASP.NET The form is submitted to the server with information The server returns the page back with error Now the page contains the information that was given at the time the page was sent to the server HOW? This is because ASP.NET maintains the viewstate

9 www.tech.findforinfo.com9 The ViewState The ViewState indicates the status of the page when submitted to the server The Status is defined through the hidden field placed on each page with a tag, the hidden fields stores information about the state Maintaining the ViewState is the default setting of the ASP.NET If you do not want to maintain the ViewState include the directive

10 www.tech.findforinfo.com10 The HTML control class The HTML server controls are available in the namespace System.Web.UI.HtmlControls

11 www.tech.findforinfo.com11 The HTML control class Class NameTag HtmlAnchor HtmlButton HtmlForm HtmlImage HtmlInputButton,

12 www.tech.findforinfo.com12 The HTML control class HtmlInputCheckbox HtmlInputControl HtmlInputFile HtmlInputHidden HtmlInputRadioButton HtmlSelect

13 www.tech.findforinfo.com13 Events Web forms are event driven means every piece of code acts in response to the specific event The HtmlButtonClass provides the Server Click event

14 www.tech.findforinfo.com14 Events Imports statement It provides access to all the important namespace Custom Page class and control variables Single event handler This event handler retrieves the value from the textbox and converts it into the respected conversion

15 www.tech.findforinfo.com15 Event handling changes Two parameters (source and e) Recommended standard for.NET It allows your code to identify the controls that sent the event Private sub convert_Serverclick(sender As Object,e as EventArgs)_ Handles convert.ServerClick

16 www.tech.findforinfo.com16 Event handling changes Second the event handler connects itself to the appropriate event using the handles clause AutoEventWireup is set to “false” so that the ASP.NET will always rely on the Handles keyword to connect to the event handlers <input type=“submit” value=“Ok” id=“convert” OnServerClick=“Convert_ServerClick” runat=“server”>

17 www.tech.findforinfo.com17 HtmlControl Classes Every html control inherits from the base class HtmlControl HtmlControl Events –ServerClick - Click is processed on the server side –ServerChange - This event reponds when a change has been made to a text or selection control

18 www.tech.findforinfo.com18 Events and Controls that provide it EventsControls that provide it ServerClickHtmlAnchor,Form,Button, InputButton,InputImage ServerChangeText,InputCheckBox, RadioButton,Select

19 www.tech.findforinfo.com19 HtmlInputImage control Click the image and the co-ordinates are to be displayed

20 www.tech.findforinfo.com20 HtmlControlBase Class Each Html control inherits from the base class HtmlControl

21 www.tech.findforinfo.com21 HtmlControl Base class PropertyDescription AttributesProvides a collection of all tag attributes and their values ControlProvides the collection of control available under current control DisabledTrue Disables the control and the user cannot interact EnableViewState True:It uses the hidden field to store the information about the page

22 www.tech.findforinfo.com22 HtmlControl Base class PropertyDescription PageProvides a reference to the web page that contains the control StyleCSS style properties that can be used to format Tag NameIndicates the name of the Html element VisibleFalse:The control is hidden from the user

23 www.tech.findforinfo.com23 HtmlContainerControl class Any html control that requires a opening and closing tag also inherits from the HtmlContainer Control - HtmlAnchor - HtmlForm - HtmlGeneric Control

24 www.tech.findforinfo.com24 HtmlContainerControl class PropertyDescription InnerHtmlHtml content between opening and closing of the tags,used for formatting,, InnertextThe text content between the opening and closing of the tags

25 www.tech.findforinfo.com25 HtmlInputControl class PropertyDescription TypeProvides the type of input control ValueReturns the content of the control as string

26 www.tech.findforinfo.com26 Page class Every web page is a custom class that inherits from the Page class

27 www.tech.findforinfo.com27 Page Class Property Fundamental PropertyDescription Application & SessionIt holds the information about the state CacheStores Objects for reuse ControlsProvides a collection of the web controls in that Page EnableViewState

28 www.tech.findforinfo.com28 Page Class Properties Fundamental PropertyDescription IsPostBackBoolean Property checks whether the Page is submitted for the first time RequestRefer to the HttpRequest object that holds the information about the current web request ResponseSet the web response or redirect the user to other web page

29 www.tech.findforinfo.com29 Page Class Properties Fundamental PropertyDescription ServerRefers to the HttpServer utility performs some tasks like URL,Html encoding UserIf the user has been authenticated then this property will be initialized with the user information

30 www.tech.findforinfo.com30 HttpRequest class The HttpRequest class encapsulates all the information related to the client request for a web page

31 www.tech.findforinfo.com31 HttpRequest class PropertyDescription ApplicationPathGets the virtual directory (URL) PhysicalPathGets the real directory (URL) BrowserProvides link to the HttpBrowserCapabilities object which contains the browser features ClientCertificateGets the security certificate if there exists one

32 www.tech.findforinfo.com32 HttpRequest class PropertyDescription CookiesGets the collection cookies sent with the request Headers\ Servervariables Provides a name\value collection of HTTP headers and server variables IsAuthenticated IsSecureConnection Returns true if user is authenticated and secure sockets are used

33 www.tech.findforinfo.com33 HttpRequest class PropertyDescription QueryStringProvides the parameters that were passed along with query string Url and UrlReferrer Current address of the page and the address of the page from where the user has navigated from UserAgentA string representing the browser type.IE provides the value “MSIE”

34 www.tech.findforinfo.com34 HttpRequest class PropertyDescription UserLanguagesProvides a sorted string array that lists the clients language

35 www.tech.findforinfo.com35 Server Variables Request Method Server Name Server Port Server Protocol Server Software

36 www.tech.findforinfo.com36 The HttpResponse Class This class allows you to send information directly to the client Some of the important functionalities Caching Support Cookie features Redirect method

37 www.tech.findforinfo.com37 PropertyDescription BufferOutputDefault set to (true) the page is not sent to the client CacheRefers to the HttpCache policy CookiesThe collection of cookies sent with response Write(), BinaryWrite() WriteFile() Allows you to write text or binary content directly to the response stream

38 www.tech.findforinfo.com38 PropertyDescription Redirect()Transfers the user to another page or another website

39 www.tech.findforinfo.com39 The Server Utility Class The ServerUtility class provides some miscellaneous helper methods

40 www.tech.findforinfo.com40 PropertyDescription CreateObjectCreates an instance of the COM object that is identified by its ID HtmlEncode, HtmlDecode Changes an ordinary string into a string with legal HTML characters UrlEncode, UrlDecode Changes an ordinary string into a string with legal URL characters

41 www.tech.findforinfo.com41 PropertyDescription MapPathReturns the Physical path TransferSimilar to response.redirect method

42 www.tech.findforinfo.com42

43 www.tech.findforinfo.com43

44 www.tech.findforinfo.com44


Download ppt "Www.tech.findforinfo.com1 Web Form Fundamentals Chapter-2 Unit-2."

Similar presentations


Ads by Google