KEMBAR78
ASP.Net Presentation Part1 | ZIP
.NetTable of contentsIntroduction to VS 2005 Application and Page Frameworks GUI Controls Validation Server Controls Working with Master Pages Themes & Skins Collections & Lists Data Binding Data Management with ADO.Net Working with XML Site Navigation Security State Management Caching Debugging & Error Handling File I/O & Streams Configurations
Introduction to VS 2005Visual Studio 2005 is an IDE that is used to create ASPX pages (Web application)Creation of web application also creates a set of files.Web application exists only in the location specified by IIS virtual folder.In a system, the web root folder is //localhost This is the virtual folderThe physical path for this virtual folder is \\inetpub\wwwroot
We can see these windows when we open the Visual StudioProperty Window – Shows the properties of a control(Page or button or textbox)Solution Explorer – Shows the files that a opened project hasOutput Window – Shows the result of a compilation or execution of a programError List – Shows the compilation errors etc.What can you find in a VS
IIS – Internet Information ServicesIIS is a web server that comes along with .NetWe can configure IIS using “inetmgr”In the Start Menu, choose Run and type inetmgr. We will get a window that lists the websites present in the system.For creating a virtual directory, right click on the default website and select New -> Virtual Directory. Give the alias name Give the physical pathGive the access permissions and click finish.
ASP .NetUsed to create web applications and web services that run under IISASP.NET is a collection of .NET classes that collaborate to process an HTTP request and generate an HTTP responseHelps us in creating Dynamic Web pagesDynamic web pages – Pages will be generated at the server based on the user’s request and then given back to the client (user)
ASP .Net FrameworkASP.NET is a managed server-side framework For building applications based on HTTP, HTML, XML and SOAPASP.NET relies on IIS for an HTTP entry pointASP.NET supports building HTML-based Web ApplicationsBased on ASP.NET pages, Web forms and server-side controlsASP.NET supports building Web ServicesBased on Web service classes and WebMethods
Life cycle of a web pagePage_Init This is called when page is initialized. We can declare some variables which need to be initialized before page is loadedPage_LoadThe server controls are loaded in the page .This event is called every time when page is loadedControl_EventThis event is fired when control like button are clicked or changedPage_UnloadThis event occurs when a page is Unloaded from memoryPage_DisposeThis event occurs when a page is released from memory
Life cycle of a web applicationThe Life of web application begins when a user requests for a page through the browser (client)When IIS receives request from client it calls ASP. NET  worker processThe ASP.NET worker process loads the assembly The executable creates an instance of web formGenerates the HTML page to respond to the requestPosts the response to browser  and then it destroys the instance of the web formThen browser receives the generated HTML
Client Performs tasks like button clickThe page’s data is sent back to serverWhen server receives this page  it creates new instance of web form Processes the event occurredThen again send back HTML and destroys the pageWhen user stops the web application for a period of time session endsLife cycle of a web application (Contd..)
ASP .Net AdvantagesExecutable portion of a web application are  compiledEnriched tool supportApplications are based on CLRCommon Language RuntimeOn the fly updates deployed without restarting serverBetter session managementIntegration with ADO.NETBuilt in features for cachingCreate XML Web services Browser-independentLanguage-independent
Application and Page Framework
ASP .Net ApplicationsEach application is based on IIS virtual directory
Each application is contained within a physical directory
Each application runs in its own isolated AppDomain
Namespace must for this application is System.WebASP .Net PagesCode and Design are separatedDesign file – ASPX fileContains ASPX or HTML tagsCode file – called as code behind fileHas the programming logicProgramming language can be C#VB .Net
ASP .Net Pages (Contd..)ASPX Page has<asp:Button id=“LookUp“ OnClick=btnSubmit_Click“ />C# file will havebtnSubmit_Click() { ... }The code behind page is inherited from System.Web.UI.Page classThe .aspx file containing the user interface is inherited from code behind  class
Files in a Web application ProjectAssemblyInfo.cs All the information about assembly including version, company name etcDefault.aspxThe visual description of a Web form. Default.aspx.csThe code behind that responds to events on the Web form Default.aspx.resxXML resources used by web formGlobal.asax The global events that occur in web applicationsWeb.configConfiguration contents like authentication mode, error files etc.
GUI Controls
Server Control
Web ControlsListControlListBoxCheckBoxListButtonTableWebControlSystem.Web.UI.ControlSystem.ObjectTextBox......
Postback eventThese events cause the web page to be sent back to the server for immediate processingWhen page is posted back ,the Page_Init, Page _Load events are handled The page is submitted back and renders a new version of itself back to the user
Validation ControlsASP .Net provides 5 validation controls that are used to check the validity of data entered by the user in the server controls on the web page.Client side validation is also possible through a Jscript library WebUIValidation.jsRequired field validatorRegular expression validatorCompare validatorRange validatorCustom validatorValidation summary
Required Field ValidatorTo check whether a control contains dataProperties:ControlToValidateErrorMessageTextMethod:Validate
Regular Expression ValidatorTo check whether the entered data matches a specific formatPropertiesControlToValidateValidationExpressionErrorMessageMethodValidate
Compare ValidatorTo compare values entered in two controlsProperties:ControlToCompareControlToValidateErrorMessageValueToCompareMethod:Validate
Range ValidatorTo compare whether the entered value is between two specified valuesProperties:ControlToValidateErrorMessageTypeMaximumValueMinimumValueMethod:Validate
To Check the validity of an entered item using a client-side script or a server-side code, or bothProperties:ControlToValidateErrorMessageEvents:ServerValidateMethod:OnServerValidateValidateCustom Validator
To Display validation errors in a central location or display a general validation error descriptionProperties:HeadTextShowMessageBoxShowSummaryValidation Summary
We can create our own controls in addition to HTML and Web controlsUser controls offer you an easy way to partition and reuse common user interface (UI) functionality across your ASP.NET Web applicationsUser controls are not compiled until run timeYou can simply drag and drop them on the page and start using themTo create a user control:Add a new item ( select user control as a template)  and give it a name – Heading.ascxThe following description can be seen in HTML view	<%@Control Language="c#" AutoEventWireup="false" Codebehind="Heading.ascx.cs“>User Controls
To use a user control, just drag the ascx file from the solution explorer and drop it on the design area of the aspx pageOr give like this in the html view of the aspx pageIn the head portion<%@Register TagPrefix="uc1" TagName="Heading" src="Heading.ascx"%>In the body portion<uc1 id=“user1”/>Using a User Control
The Calendar Web server control displays a traditional one-month calendar on your Web Forms pagesFew properties:SelectedDateSelectedDatesBackColorFew methods:AddDays()AddMonths()AddYears()GetMonth()GetYear()GetDayOfWeek()IsLeapYear()Calendar Control
DateTime is a static class. Members can be accessed via DateTime.Now and so on.The DateTime value type represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Common Era to 11:59:59 P.M., December 31, 9999 C.E.Few properties:TodayNowDateFew Methods:AddDays()AddMonths()Compare()ToLongDateString()ToShortDateString()DateTime
Full-featured list outputDefault is to show all columnsCan specify a subset of columns to displayProvides templatesStandard CustomProvides pagingProvides data updatesDataGrid Control
Provides simple output of list of itemsTemplates provide the visual formIt iterates over the bound dataDisplay format of data is managedDoes not support pagingProvides templates for separatorsDoes not provide data updatesRepeater Control

ASP.Net Presentation Part1

  • 1.
    .NetTable of contentsIntroductionto VS 2005 Application and Page Frameworks GUI Controls Validation Server Controls Working with Master Pages Themes & Skins Collections & Lists Data Binding Data Management with ADO.Net Working with XML Site Navigation Security State Management Caching Debugging & Error Handling File I/O & Streams Configurations
  • 2.
    Introduction to VS2005Visual Studio 2005 is an IDE that is used to create ASPX pages (Web application)Creation of web application also creates a set of files.Web application exists only in the location specified by IIS virtual folder.In a system, the web root folder is //localhost This is the virtual folderThe physical path for this virtual folder is \\inetpub\wwwroot
  • 3.
    We can seethese windows when we open the Visual StudioProperty Window – Shows the properties of a control(Page or button or textbox)Solution Explorer – Shows the files that a opened project hasOutput Window – Shows the result of a compilation or execution of a programError List – Shows the compilation errors etc.What can you find in a VS
  • 4.
    IIS – InternetInformation ServicesIIS is a web server that comes along with .NetWe can configure IIS using “inetmgr”In the Start Menu, choose Run and type inetmgr. We will get a window that lists the websites present in the system.For creating a virtual directory, right click on the default website and select New -> Virtual Directory. Give the alias name Give the physical pathGive the access permissions and click finish.
  • 5.
    ASP .NetUsed tocreate web applications and web services that run under IISASP.NET is a collection of .NET classes that collaborate to process an HTTP request and generate an HTTP responseHelps us in creating Dynamic Web pagesDynamic web pages – Pages will be generated at the server based on the user’s request and then given back to the client (user)
  • 6.
    ASP .Net FrameworkASP.NETis a managed server-side framework For building applications based on HTTP, HTML, XML and SOAPASP.NET relies on IIS for an HTTP entry pointASP.NET supports building HTML-based Web ApplicationsBased on ASP.NET pages, Web forms and server-side controlsASP.NET supports building Web ServicesBased on Web service classes and WebMethods
  • 7.
    Life cycle ofa web pagePage_Init This is called when page is initialized. We can declare some variables which need to be initialized before page is loadedPage_LoadThe server controls are loaded in the page .This event is called every time when page is loadedControl_EventThis event is fired when control like button are clicked or changedPage_UnloadThis event occurs when a page is Unloaded from memoryPage_DisposeThis event occurs when a page is released from memory
  • 8.
    Life cycle ofa web applicationThe Life of web application begins when a user requests for a page through the browser (client)When IIS receives request from client it calls ASP. NET worker processThe ASP.NET worker process loads the assembly The executable creates an instance of web formGenerates the HTML page to respond to the requestPosts the response to browser and then it destroys the instance of the web formThen browser receives the generated HTML
  • 9.
    Client Performs taskslike button clickThe page’s data is sent back to serverWhen server receives this page it creates new instance of web form Processes the event occurredThen again send back HTML and destroys the pageWhen user stops the web application for a period of time session endsLife cycle of a web application (Contd..)
  • 10.
    ASP .Net AdvantagesExecutableportion of a web application are compiledEnriched tool supportApplications are based on CLRCommon Language RuntimeOn the fly updates deployed without restarting serverBetter session managementIntegration with ADO.NETBuilt in features for cachingCreate XML Web services Browser-independentLanguage-independent
  • 11.
  • 12.
    ASP .Net ApplicationsEachapplication is based on IIS virtual directory
  • 13.
    Each application iscontained within a physical directory
  • 14.
    Each application runsin its own isolated AppDomain
  • 15.
    Namespace must forthis application is System.WebASP .Net PagesCode and Design are separatedDesign file – ASPX fileContains ASPX or HTML tagsCode file – called as code behind fileHas the programming logicProgramming language can be C#VB .Net
  • 16.
    ASP .Net Pages(Contd..)ASPX Page has<asp:Button id=“LookUp“ OnClick=btnSubmit_Click“ />C# file will havebtnSubmit_Click() { ... }The code behind page is inherited from System.Web.UI.Page classThe .aspx file containing the user interface is inherited from code behind class
  • 17.
    Files in aWeb application ProjectAssemblyInfo.cs All the information about assembly including version, company name etcDefault.aspxThe visual description of a Web form. Default.aspx.csThe code behind that responds to events on the Web form Default.aspx.resxXML resources used by web formGlobal.asax The global events that occur in web applicationsWeb.configConfiguration contents like authentication mode, error files etc.
  • 18.
  • 19.
  • 20.
  • 21.
    Postback eventThese eventscause the web page to be sent back to the server for immediate processingWhen page is posted back ,the Page_Init, Page _Load events are handled The page is submitted back and renders a new version of itself back to the user
  • 22.
    Validation ControlsASP .Netprovides 5 validation controls that are used to check the validity of data entered by the user in the server controls on the web page.Client side validation is also possible through a Jscript library WebUIValidation.jsRequired field validatorRegular expression validatorCompare validatorRange validatorCustom validatorValidation summary
  • 23.
    Required Field ValidatorTocheck whether a control contains dataProperties:ControlToValidateErrorMessageTextMethod:Validate
  • 24.
    Regular Expression ValidatorTocheck whether the entered data matches a specific formatPropertiesControlToValidateValidationExpressionErrorMessageMethodValidate
  • 25.
    Compare ValidatorTo comparevalues entered in two controlsProperties:ControlToCompareControlToValidateErrorMessageValueToCompareMethod:Validate
  • 26.
    Range ValidatorTo comparewhether the entered value is between two specified valuesProperties:ControlToValidateErrorMessageTypeMaximumValueMinimumValueMethod:Validate
  • 27.
    To Check thevalidity of an entered item using a client-side script or a server-side code, or bothProperties:ControlToValidateErrorMessageEvents:ServerValidateMethod:OnServerValidateValidateCustom Validator
  • 28.
    To Display validationerrors in a central location or display a general validation error descriptionProperties:HeadTextShowMessageBoxShowSummaryValidation Summary
  • 29.
    We can createour own controls in addition to HTML and Web controlsUser controls offer you an easy way to partition and reuse common user interface (UI) functionality across your ASP.NET Web applicationsUser controls are not compiled until run timeYou can simply drag and drop them on the page and start using themTo create a user control:Add a new item ( select user control as a template) and give it a name – Heading.ascxThe following description can be seen in HTML view <%@Control Language="c#" AutoEventWireup="false" Codebehind="Heading.ascx.cs“>User Controls
  • 30.
    To use auser control, just drag the ascx file from the solution explorer and drop it on the design area of the aspx pageOr give like this in the html view of the aspx pageIn the head portion<%@Register TagPrefix="uc1" TagName="Heading" src="Heading.ascx"%>In the body portion<uc1 id=“user1”/>Using a User Control
  • 31.
    The Calendar Webserver control displays a traditional one-month calendar on your Web Forms pagesFew properties:SelectedDateSelectedDatesBackColorFew methods:AddDays()AddMonths()AddYears()GetMonth()GetYear()GetDayOfWeek()IsLeapYear()Calendar Control
  • 32.
    DateTime is astatic class. Members can be accessed via DateTime.Now and so on.The DateTime value type represents dates and times with values ranging from 12:00:00 midnight, January 1, 0001 Common Era to 11:59:59 P.M., December 31, 9999 C.E.Few properties:TodayNowDateFew Methods:AddDays()AddMonths()Compare()ToLongDateString()ToShortDateString()DateTime
  • 33.
    Full-featured list outputDefaultis to show all columnsCan specify a subset of columns to displayProvides templatesStandard CustomProvides pagingProvides data updatesDataGrid Control
  • 34.
    Provides simple outputof list of itemsTemplates provide the visual formIt iterates over the bound dataDisplay format of data is managedDoes not support pagingProvides templates for separatorsDoes not provide data updatesRepeater Control
  • 35.
    HeaderTemplateRendered beforeall data bound rowsItemTemplateRendered for each row in the data sourceAlternatingItemTemplateRendered for every other row SeparatorTemplateRendered between each rowFooterTemplateRendered after all data bound rowsStandard templates for Repeater controls
  • 36.
    To bind embeddedcontrols to the data source of the container controlDataBinder.Eval() method is usedSyntax<%#DataBinder.Eval(Container.DataItem,“DataFieldname")%>Container represents the container for data items DataFieldname represents the name of data item fieldBinding data