2. Agenda 1. Introduction 2. Asp.net Architecture 3. Asp.net Web Server Controls 4. Asp.net Page life Cycle 5. Relation with SharePoint 2010 8. User Controls in asp.net 9. Ajax in asp.net 10. LINQ in asp.net 11. WFF 12. Relation with SharePoint 2010
3. Introduction What is ASP.NET? ASP.NET is a server side scripting technology that enables scripts (embedded in web pages) to be executed by an Internet server. ASP.NET is a Microsoft Technology ASP stands for Active Server Pages ASP.NET is a program that runs inside IIS IIS (Internet Information Services) is Microsoft's Internet server IIS comes as a free component with Windows servers IIS is also a part of Windows 2000 and XP Professional
4. Introduction What is an ASP.NET File? An ASP.NET file is just the same as an HTML file An ASP.NET file can contain HTML, XML, and scripts Scripts in an ASP.NET file are executed on the server An ASP.NET file has the file extension ".aspx“ How Does ASP.NET Work? When a browser requests an HTML file, the server returns the file When a browser requests an ASP.NET file, IIS passes the request to the ASP.NET engine on the server The ASP.NET engine reads the file, line by line, and executes the scripts in the file Finally, the ASP.NET file is returned to the browser as plain HTML
5. The Microsoft .NET Framework The .NET Framework is the infrastructure for the Microsoft .NET platform. The .NET Framework is an environment for building, deploying, and running Web applications and Web Services. .NET Frameworks keywords: Easier and quicker programming Reduced amount of code Declarative programming model Richer server control hierarchy with events Larger class library Better support for development tools
6. The Microsoft .NET Framework The .NET Framework consists of 3 main parts: Programming languages: C# (Pronounced C sharp) Visual Basic (VB .NET) J# (Pronounced J sharp) Server technologies and client technologies: ASP .NET (Active Server Pages) Windows Forms (Windows desktop solutions) Compact Framework (PDA / Mobile solutions) Development environments: Visual Studio .NET (VS .NET) Visual Web Developer
7. Advantages of ASP.NET Web application exists in compiled form on the server so the execution speed is faster as compared to the interpreted scripts. ASP.NET makes development simpler and easier to maintain with an event-driven, server-side programming model. Being part of .Framework, it has access to all the features of .Net Framework. Content and program logic are separated which reduces the inconveniences of program maintenance. ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in.
8. Advantages of ASP.NET To develop program logic, a developer can choose to write their code in more than 25 .Net languages including VB.Net, C#, JScript.Net etc. Introduction of view state helps in maintaining state of the controls automatically between the postbacks events. ASP.NET offers built-in security features through windows authentication or other authentication methods. The Web server continuously monitors the pages, components and applications running on it. If it notices any memory leaks, infinite loops, other illegal activities, it immediately destroys those activities and restarts itself. Integrated with ADO.NET. Built-in caching features.
10. Three Tier Architecture in ASP.NET These layers are described below. 1. Application layer or Business layer2. Business layer a. Property layer(Sub layer of business layer)3. data layer
11. Three Tier Architecture in ASP.NET Application layer is the form where we design using the controls like textbox, labels, command buttons etc. Business layer is the class where we write the functions which get the data from the application layer and passes through the data access layer. Data layer is also the class which gets the data from the business layer and sends it to the database or gets the data from the database and sends it to the business layer. Property layer is the sub layer of the business layer in which we make the properties to sent or get the values from the application layer. These properties help to sustain the value in a object so that we can get these values till the object destroy.
13. ASP.NET Web Server Controls Standard Toolbox Controls Data Toolbox Controls Validation Toolbox Controls Navigation Toolbox Controls Login Toolbox Controls WebParts Toolbox Controls HTML Controls for ASP.NET Web Pages Ajax Server Controls Microsoft Ajax Extender Controls
16. General Page life-Cycle Stages Page request:- The page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page. Start:- In the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. Initialization:- During page initialization, controls on the page are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
17. General Page life-Cycle Stages Load:- During load, if the current request is a postback, control properties are loaded with information recovered from view state and control state. Postback event handling:- If the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page. Rendering:- Before rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property. Unload:- The Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and cleanup is performed.
18. Life-Cycle Events PreInit :- Raised after the start stage is complete and before the initialization stage begins. Use this event for the following: Check the IsPostBack property to determine whether this is the first time the page is being processed. The IsCallback and IsCrossPagePostBack properties have also been set at this time. Create or re-create dynamic controls. Set a master page dynamically. Set the Theme property dynamically. Read or set profile property values. Init :- Raised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page. Use this event to read or initialize control properties.
19. General Page life-Cycle Stages InitComplete :- Raised at the end of the page's initialization stage. Only one operation takes place between the Init and InitComplete events: tracking of view state changes is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Init event. Use this event to make changes to view state that you want to make sure are persisted after the next postback. PreLoad :- Raised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance.
20. General Page life-Cycle Stages Load :- The Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page. Use the OnLoad event method to set properties in controls and to establish database connections. Control events:- Use these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event. LoadComplete :- Raised at the end of the event-handling stage. Use this event for tasks that require that all other controls on the page be loaded.
21. General Page life-Cycle Stages PreRender :- Raised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls. (To do this, the Page object calls EnsureChildControls for each control and for the page. The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page. Use the event to make final changes to the contents of the page or its controls before the rendering stage begins. PreRenderComplete:- Raised after each data bound control whose DataSourceID property is set calls its DataBind method.
22. General Page life-Cycle Stages SaveStateComplete :- Raised after view state and control state have been saved for the page and for all controls. Any changes to the page or controls at this point affect rendering, but the changes will not be retrieved on the next postback. Render :- This is not an event; instead, at this stage of processing, the Page object calls this method on each control. All ASP.NET Web server controls have a Render method that writes out the control's markup to send to the browser. Unload :- Raised for each control and then for the page. In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.
23. The following figure illustrates how the server controls on an ASP.NET page is processed by the server
26. State Management in asp.net ASP.NET includes several options that help you preserve data on both a per-page basis and an application-wide basis. These features are as follows: Client Side State Management:- View state Control state Hidden fields Cookies Query strings Server Side State Management:- Application state Session state
27. Client-Based State Management Options View State:- The ViewState property provides a dictionary object for retaining values between multiple requests for the same page. This is the default method that the page uses to preserve page and control property values between round trips. When the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field. View State is a built in feature in web controls to persist data between page post backs. // Add item to ViewState ViewState["myviewstate"] = myValue; //Reading items from ViewStateResponse.Write(ViewState["myviewstate"]);
28. Client-Based State Management Options Control State:- The ControlState property allows you to persist property information that is specific to a control and cannot be turned off like the ViewState property. Control state can be used to store critical, private information across post backs. Control state is another type of state container reserved for controls to maintain their core behavioral functionality whereas View State only contains state to maintain control's contents (UI).
29. Client-Based State Management Options Hidden Fields:- A HiddenField control stores a single variable in its Value property and must be explicitly added to the page. It's just like a standard control for which you can set its properties. protected System.Web.UI.HtmlControls.HtmlInputHidden Hidden1; //to assign a value to Hidden field Hidden1.Value="Create hidden fields"; //to retrieve a value string str=Hidden1.Value;
30. Client-Based State Management Options Cookie: A cookie is a small piece of text stored on user's computer. Usually, information is stored as name-value pairs. Cookies are used by websites to keep track of visitors. Every time a user visits a website, cookies are retrieved from user machine and help identify the user. Let's see an example which makes use of cookies to customize web page.if (Request.Cookies["UserId"] != null) lbMessage.text = "Dear" + Request.Cookies["UserId"].Value + ", Welcome to our website!";else lbMessage.text = "Guest,welcome to our website!"; If you want to store client's information use the below code Response.Cookies["UserId"].Value=username;
31. Client-Based State Management Options Query strings: Query strings are usually used to send information from one page to another page. They are passed along with URL in clear text. We can only pass smaller amounts of data using query strings. Since Query strings are sent in clear text, we can also encrypt query values string productid;productid=Request.Params["productid"];
32. Server Side State management: Application object: Application object is used to store data which is visible across entire application and shared across multiple user sessions. Data which needs to be persisted for entire life of application should be stored in application object. In classic ASP, application object is used to store connection strings. It's a great place to store data which changes infrequently. We should write to application variable only in application_Onstart event (global.asax) or application.lock event to avoid data conflicts. Below code sample gives idea Application.Lock(); Application["mydata"]="mydata"; Application.UnLock();
33. Server Side State management: Session object: Session object is used to store state specific information per client basis. It is specific to particular user. Session data persists for the duration of user session you can store session's data on web server in different ways. Session state can be configured using the <session State> section in the application's web.config file. Configuration information:<sessionState mode = <"inproc" | "sqlserver" | "stateserver"> timeout = <positive integer indicating the session timeout in minutes> sqlconnectionstring = <SQL connection string that is only used in the SQLServer mode> server = <The server name that is only required when the mode is State Server> port = <The port number that is only required when the mode is State Server> Mode:This setting supports three options. They are InProc, SQLServer, and State Server
34. Using Session State in SharePoint 2010 SharePoint 2010 uses two services related to session state that have similar names but are separate and have different purposes. ASP.NET session state may be used on SharePoint 2010 pages. This service is automatically disabled in normal installations of SharePoint 2010; it may be enabled using the instructions below. Once enabled, it appears on the Service Applications page as “SharePoint Server ASP.NET Session State Service.” The State Service service application is designed for and only available to Office internal components such as InfoPath Forms Services and Visio Services. This service is automatically enabled in typical installations of SharePoint 2010 and is not related to ASP.NET session state. It appears on the Service Applications page as “State Service.”
35. User Control in Asp.net Refer Parallelminds_Asp.net3.5_with_SP from Solution
36. User Control in Asp.netWhen a page with a user control is requested The page parser parses the .ascx file specified in the Src attribute in the @ Register directive and generates a class that derives from the System.Web.UI.UserControl class. The parser then dynamically compiles the class into an assembly. If you are using Visual Studio, then at design time only, Visual Studio creates a code behind file for the user control, and the file is precompiled by the designer itself. Finally, the class for the user control, which is generated through the process of dynamic code generation and compilation, includes the code for the code behind file (.ascx.cs) as well as the code written inside the .ascx file.
42. AJAX in asp.net Ajax enables you to build highly interactive and responsive web applications by doing more in the browser. provides a framework for asynchronously dispatching and processing requests and responses from the server. The ASP.NET Ajax Library enables you to enhance ASP.NET Web Forms applications with Ajax. You don't need to know JavaScript to use the controls in the ASP.NET Ajax Library. The ASP.NET Ajax Library includes the Ajax Control Toolkit. The Ajax Library contains more than 30 controls that enable you to easily create rich, interactive web pages. For example, you can use the Ajax Library controls to display HTML editors, auto-complete textboxes, cascading dropdown lists, picture slide shows, and modal popup dialog boxes.
43. Ajax Server Controls The topics in this section describe how to work with ASP.NET Web server controls that enable you to add Ajax functionality to an ASP.NET Web page. ScriptManager Control OverviewManages client script for Ajax-enabled ASP.NET pages. By default, the ScriptManager control registers the script for the Microsoft Ajax Library with the page. This enables client script to use the Microsoft Ajax type system extensions and to support features such as partial-page rendering and Web-service calls. In addition, theScriptManager control enables the Microsoft Ajax Library to be loaded from the Microsoft Content Delivery Network (CDN). Timer Control OverviewPerforms tasks at defined intervals. If you use the Timer control with an UpdatePanel control, you can enable partial-page updates at a defined interval. You can also use the Timer control to perform full-page postbacks.
44. Ajax Server Controls UpdatePanel Control OverviewEnables you to refresh selected parts of the page instead of refreshing the whole page with a postback. An ASP.NET Web page that contains a ScriptManager control and one or more UpdatePanel controls can automatically participate in partial-page updates, without custom client script. UpdateProgress Control OverviewEnables you to provide status information about partial-page updates in UpdatePanel controls.
52. AJAX in SharePoint 2010 SharePoint Ajax Library for SharePoint 2010, release 1.1. SharePoint Ajax Library 2010 1.1 This is a base framework built on top of the Microsoft AJAX Library and ASP.NET AJAX for deploying client-side AJAX Web Parts and controls that work against web services and Xml feeds utilizing the ASP.NET AJAX framework.
54. Caching in asp.net Caching allows you to use a number of techniques to store page output or application data across HTTP requests and reuse it. ASP.NET provides two types of caching that you can use to create high-performance Web applications The first is called output caching, which allows you to store dynamic page and user control responses on any HTTP 1.1 cache-capable device in the output stream, from the originating server to the requesting browser. The second type of caching is traditional application data caching, which you can use to programmatically store arbitrary objects, such as data sets, to server memory so that your application can save the time and resources it takes to recreate them.
55. Caching in asp.net Caching ASP.NET Pages Describes the required modifications you must make to a page to take advantage of page output caching. This includes details about how you can vary the caching of page output, dependent upon requesting URIs, GET query string or form POST parameters, and custom strings. Caching Portions of an ASP.NET Page Describes the techniques you can use to cache regions of your pages using the @ OutputCache directive and user controls. This technique is useful if you do not want to cache entire pages. Caching Application Data Outlines the concepts behind using the ASP.NET application cache and provides samples of how to use its classes, methods, and properties.
64. Caching techniques in SharePoint 2010 In SharePoint 2010, there's a few different ways to cache data. Output Caching :- you can configure your SharePoint 2010 site to cache the Pages it outputs. The page output cache stores the rendered output of a page. It also stores different versions of the cached page, based on the permissions of the users who are requesting the page. Page output cache settings can be configured at the site collection level, at the site level, and for page layouts. By default, the page output cache is turned off. The page output cache uses cache profiles that specify how long items should be held in the cache. You can specify different cache profiles to be used for anonymous and authenticated users, which optimizes the use of the cache based on the authentication methods that are allowed on the site. You can configure cache profile settings for a Web application by editing the Web.config file on the application server
65. Caching techniques in SharePoint 2010 Object Caching :- A mechanism to cache specific page items. This is especially likable if you're playing around with Cross-List data queries and need to cache the results of such a query. Microsoft SharePoint Server 2010 supports caching of certain page items, such as navigation data and data accessed through cross-list queries. Caching page items is fast and eliminates the need to retrieve field data from the database each time a page is rendered. Caching for objects in a page can almost always be used. When users have a document checked out, the cache is bypassed. The object cache reduces the amount of traffic between the Web server and the SQL database by storing objects—such as lists and libraries, site settings, and page layouts—in memory on the front-end Web server computer. Object cache settings can be configured at the Web application level, and at the site collection level.
66. Caching techniques in SharePoint 2010 BLOB Cache :- The BLOB cache is enabled and configured in the Web.config file in the Web application to which you want to apply the cache. It is a disk-based caching mechanism that caches resources on the disk. Normally these resources are files served by a web page and are named Binary Large Objects (BLOB). Normally the BLOB cache will cache files served by the web request like images and video clips. The first time that a Web page is called, these files are copied from the database to the cache on the server hard disk drive, and all subsequent requests for those files are then served from the hard disk drive cache of the server. By default, the BLOB cache is off and must be enabled to use the functionality it provides. When you enable the BLOB cache on your front-end Web server, you reduce the load on the SharePoint Server 2010 database server created by read requests from Web browsers.
67. Interacting with Get and Post methods in asp.net There are two common ways to pass data from one page to another, using http Get and Post methods. In Get method, data passed to server using URL encoding. So with Get method data added in URL as query string. When we use Post method the URL is still intact, because data passed in HTTP body. In correlation with ASP.NET, retrieving data passed through HTTP Get and Post methods is quite simple. If data passed with Get method we need the following code to retrieve the data: Page.Request.QueryString[<param>]; If data passed with Post method we need the following code to retrieve the data: Page.Request.Form[<param>];
68. How to use GET and POST methods in asp.net Refer Parallelminds_Asp.net3.5_with_SP from Solution
76. LINQ in asp.net Refer Parallelminds_LINQ_To_Object from Solution
77. LINQ in asp.net Language Integrated Query is the new addition to the .NETfamily and as the name suggests it’s the kind of query style data access. which is fully supported by the language to effectively unify the way we access data and to make our lives easier. LINQ is able to target a number of different sources namely Oracle,MSSQL, XML and a few others.
78. LINQ in asp.net You can use Language-Integrated Query (LINQ) in Web pages to retrieve and modify data. LINQ applies the principles of object-oriented programming to relational data. It provides a unified programming model for querying data from different types of data sources, and extends data capabilities directly into the C# and Visual Basic languages. This means we can use any relational or XML-specific features to our programming languages and runtime. To display the data in a Web page, you bind a data-bound control to the LinqDataSource control. Examples of data-bound controls are the GridView or DetailsView controls.
79. LINQ in asp.net LINQ to Object LINQ to SQL Server LINQ to XML You can use LINQ through the LinqDataSource control, through the ObjectDataSource control, or by creating LINQ queries. When you retrieve data from a LINQ to SQL data context class, you can also configure a LinqDataSource control to handle update, insert, and delete operations. The control does this without requiring you to write the SQL commands to perform these tasks.
80. LINQ to Objects LINQ supports the “select”, “from”, “where”, “join”, “group by”and “order by” keywords. The main difference between SQL and LINQ is that the “from” keyword comes before the “select” keyword because we must first define the object we want to operate on. Finally the “select” clause tells the compiler what we wish to extract in this query. The result of LINQ queries is always a collection like datastructure which allows for iterating through it using a loop The LINQ query does not execute until its result isaccessed by some other piece of code, like the “foreach” loop
81. VS -> Create Project ->Console Appln. LINQ to Objects
94. LINQ for SharePoint 2010 The LINQ to SharePoint Provider is defined in the Microsoft.SharePoint.Linq namespace. It translates LINQ queries into Collaborative Application Markup Language (CAML) queries. LINQ to SharePoint is a technology for querying SharePoint lists that relieves the developer from having to write CAML queries. In this, you will be making use of the new support for LINQ in SharePoint. In the first step, you will be creating lists for use with LINQ. In the second step, you will use the SPMETAL utility to create Entities. In the final stage, you will create a web part for accessing the list data using LINQ.
95. Windows Work Flow Foundation(WFF) Refer Parallelminds_WorkflowConsoleApplication from Solution
96. Windows Work Flow Foundation(WFF) Windows Workflow Foundation (WF) is one of the parts of the .NET 3.0 framework as released by Microsoft. One of the most interesting aspects of Windows Workflow Foundation (WF) is the separation between business process code and the actual implementation, often a requirement in Service Oriented Architecture (SOA). With the release of Windows Workflow Foundation (WF) the business logic can be defined in the workflow while the actual underlying implementation is done in C# or another .NET language. Windows Workflow Foundation is basically a library consisting of an execution engine, a rules engine, a number of activities, a number of supporting runtime services and a designer allowing developers to design their workflows graphical in Visual Studio.
116. SharePoint and Windows WF Windows SharePoint Services (WSS) 2007 is the first Microsoft server that has native support for the Windows WorkFlow Foundation (WF). It provides an infrastructure that drives processes around SharePoint's strong suit: collaboration and sharing of information. This release focuses on document-centric workflows, the procedures that a particular document goes through in its lifecycle The new edition enables you to attach and run a process directly in a SharePoint document or list item. The WorkFlow Foundation provides an extensible infrastructure that can be used to create sophisticated workflows. WF provides a powerful platform with a unified programming model, and it works with familiar developmental tools such as Visual Studio 2005.
117. SharePoint and Windows WF The first step in creating a workflow for SharePoint is crafting a new project in Visual Studio based in the Sequential Workflow Library (or in the State Machine Workflow Library, if you are making a state machine workflow) and assigning it a name. Visual Studio will generate the necessary code and configuration files. Add a reference to Windows SharePoint Services (Microsoft.SharePoint.dll) and, if you need to work with Microsoft Office SharePoint Server, a reference to Microsoft Office SharePoint Server component (microsoft.sharepoint.portal.dll). This establishes references to the object model of SharePoint, opening the door to interactions with it.
118. SharePoint and Windows WF You can use workflows to manage a business process or any series of tasks required to get a job done. for example, to manage expense reporting, the hiring process, or a company event. There are several types of workflows you can choose from, including the Approval workflow, the Collect Feedback workflow, and Collect Signatures workflow. For example, the approval workflow, to get a document approved before sending it out to the rest of the company. Visio 2010 comes with a brand new template; Microsoft SharePoint Workflow. Using this template you can design your workflow and then export it.