Definitions

Stored Procedure:

Stored procedures are precompiled database queries that improve the security, efficiency and usability of database client/server applications. Developers specify a stored procedure in terms of input and output variables. They then compile the code on the database platform and make it available to aplication developers for use in other environments, such as web applications. All of the major database platforms, including Oracle, SQL Server and MySQL support stored procedures. The major benefits of this technology are the substantial performance gains from precompiled execution, the reduction of client/server traffic, development efficiency gains from code reuse and abstraction and the security controls inherent in granting users permissions on specific stored procedures instead of the underlying database tables.

What is Polymorphism?

 Generally, the ability to appear in many forms. In object-oriented programming, polymorphism refers to a programming language's ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes. For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language (OOPL). 

There Are Two Types of Polymorphism

  1. Static Polymorphism
  2. Dynamic Polymorphism

1. Static Polymorphism
In Static Polymorphism ,Which method is to be called is decided at compile-time only. Method Overloading is an example of Static Polymorphism.

Method overloading is a concept where we use the same method name many times in the same class,but different parameters. Depending on the parameters we pass, it is decided at compile-time only, which method is to calles. The same method name with the same parameters is an error and it is a case of duplication of methods which c# does not permits. In Static Polymorphism decision is taken at compile time.
public Class StaticPolyDemo
{
  public void display(int x)
 {
    Console.WriteLine(“Area of a Square:”+x*x);
 }
  public void display(int x, int y)
 {
    Console.WriteLine(“Area of a Square:”+x*y);
 }
 public static void main(String args[])
 {
    StaticPolyDemo spd=new StaticPolyDemo();
    Spd.display(5);
   Spd.display(10,3);
 }
}

2. Dyanamic Polymorphism
In this Mechanism by which a call to an overridden function is resolved at a Run-Time( not at Compile-time). If a BaseClass contains method must be a Virtual method in C# to be overridden..

Class Test
{
  Public virtual void show()
 {  
  Console.WriteLine(“From base class show method”);
    }
}
Public Class DynamicPolyDemo : Test
{
   Public  override void show()
   {
         Console.WriteLine(“From Derived Class show method”);
   }
   Public static void main(String args[])
   {
       DynamicPolyDemo dpd=new DynamicPolyDemo();
      Dpd.show();
       
    }
}

 What is the Difference between AJAX and Javascript?

AJAX is a part of Javascript programming. Javascript is just
a client-side scripting language that is used to control a
web page once a user has downloaded the page. AJAX is a
particular usage of Javascript in which javascript
communicates with the remote script and receives the
response from the server, without having to reload the whole
page.

Javascript is a client-side scripting programming
language... AJAX is a technique incorporating the use of
Javascript, a server-side scripting language, and XML. But
javascript is the main core of ajax-based systems. AJAX
stands for Asynchronous Javascript and XML

 

What is CSS?

CSS was first developed in 1997, as a way for Web developers to define the look and feel of their Web pages. It was intended to allow developers to separate content from design so that HTML could perform more of the function that it was originally based on - the markup of content, without worry about the design and layout.
CSS didn't gain in popularity until around 2000, when Web browsers began using more than the basic font and color aspects of CSS. And now, all modern browsers support all of CSS Level 1, most of CSS Level 2, and some aspects of CSS Level 3.
Web Designers that don't use CSS for their design and development of Web sites are rapidly becoming a thing of the past. And it is arguably as important to understand CSS as it is to know HTML - and some would say it was more important to know CSS.

CSS is an Abbreviation

It stands for Cascading Style Sheet.
Style sheet refers to the document itself. Style sheets have been used for document design for years. They are the technical specifications for a layout, whether print or online. Print designers use style sheets to insure that their designs are printed exactly to specifications. A style sheet for a Web page serves the same purpose, but with the added functionality of also telling the viewing engine (the Web browser) how to render the document being viewed.
Cascade is the special part. A Web style sheet is intended to cascade through a series of style sheets, like a river over a waterfall. The water in the river hits all the rocks in the waterfall, but only the ones at the bottom affect exactly where the water will flow. The same is true of the cascade in Web style sheets.
Every Web page is affected by at least one style sheet, even if the Web designer doesn't apply any styles. This style sheet is the user agent style sheet - the default styles that the Web browser will use to display a page if no other instructions are provided. But if the designer provides other instructions, the browser needs to know which instructions have precedence.
For example, in my Web browser, the default font is "Times New Roman" size 16. But nearly no pages I visit display in that font family and size. This is because the cascade defines the second style sheets set by the designers to redefine the font size and family and override my Web browser's defaults.

Where is CSS Used?

CSS is used to style Web pages. But there is more to it than that. CSS is used to style XHTML and XML markup. This means that anywhere you have XML markup (including XHTML) you can use CSS to define how it will look.
CSS is also used to define how Web pages should look when viewed in other media than a Web browser. For example, you can create a print style sheet that will define how the Web page should print out and another style sheet to display the Web page on a projector for a slide show.

Why is CSS Important?

CSS is one of the most powerful tools a Web designer can learn because with it you can affect the entire mood and tone of a Web site. Well written style sheets can be updated quickly and allow sites to change what is prioritized or valued without any changes to the underlying XHTML.
The challenge of CSS is that there is so much to learn. But it doesn't seem like it. After all, there are only around 60 properties in CSS Level 1 and around 70 in CSS Level 2. Compared with the number of HTML tags and attributes to learn, that can feel like a cake walk.
But because CSS can cascade, and combine and browsers interpret the directives differently, CSS is more difficult than plain HTML. But once you start using it, you'll see that harnessing the power of CSS will give you more options and allow you to do more and more things with your Web sites.
If you want to be a professional Web designer, you need to learn Cascading Style Sheets. But luckily, they are fun to learn.

What is Javascript?

What exactly is Javascript?:
Javascript is a programming language that is used to make web pages interactive. It runs on your visitor's computer and so does not require constant downloads from your web site.
Are Javascript and Java the same?:
No, they are two completely different computer languages. Only their names are similar.
What do I need to run Javascript?:
Javascript support is built right into web browsers. Provided that the visitors to your site are using web browsers that support Javascript (most do) and have Javascript enabled (it is by default) then your Javascript will run.
Do I need to learn Javascript to be able to use it?:
No. There are plenty of Javascripts that have already been written that people have made available for you to plug straight into your web page. All you need to know to be able to use such scripts is how to paste the supplied code into the required places in your web page.
What do I need to write Javascript?:
Javascript is an interpreted language and so no special program is required to be able to create usable code. Any plain text editor such as Notepad is quite satisfactory for being able to write Javascript. That said, an editor which colourizes the code to make it easier to see what is what makes it easier to find your mistakes but then my Javascript Formatter can reformat your script to make errors even easier to spot.
Can I use HTML instead of Javascript?:
No. HTML and Javascript are two completely different things. HTML is a markup language designed for defining static web page content. Javascript is a programming language designed for performing dynamic tasks.
Can I use PHP or some other server side language instead of Javascript?:
Perhaps, it depends on where the code needs to run. If it can run before the page loads you can use a server side language. If it has to run after the page has loaded then you must use Javascript as this is the only scripting language supported by all web browsers that support client side scripting.
Does the Javascript go in the same file as the HTML?:
It can but your scripts will be more easily reused on multiple pages of your site if you place them in separate files (using a .js extension helps identify them as Javascript). You then just link the Javascript to your HTML by inserting a <script> tag. The same Javascript can then be added to several pages just by adding the appropriate tag into each of the pages to set up the link.

 


 

 

What Is JavaScript

What is JavaScript?

JavaScript is a compact, object-based scripting language for Web pages. JavaScript code embedded into your HTML pages can enhance them with many interesting elements, from swapping images when you move a cursor over them, to multi-level drop-down menus.
You can create really sophisticated and almost application-like pages with the help of JavaScript. You don't need any special software other than a text editor and a Web browser, and you don't need access to a Web server. You can create and test all your JavaScript code right on your own computer.

JavaScript and Java

Although the names are almost the same, JavaScript isn't the same as Java. These are two different techniques for Internet programming. Java is a real programming language, and you can create real programs with it.
JavaScript is a scripting language. You could even say that JavaScript is rather an extension to HTML than a separate computer language. It's so tightly integrated with HTML that you could call it "JavaScript markup language." JavaScript coders don't care too much about real programming, they just make different nice effects by inserting small JavaScript code fragments into their Web pages.

The drawbacks of JavaScript

Right now the biggest problem is the imperfect JavaScript implementations that today's browsers offer. Although all major browsers that are version 3.0 or higher include JavaScript support, they deal with JavaScript differently.
In fact, different versions of the same browser handle JavaScript differently. This makes it difficult to create a complicated JavaScript code that work across all browsers. So always check your pages on as many different browsers (and even platforms) as possible.

What do JavaScript code look like?

Like HTML, JavaScript is just text that can be typed into a text editor. Its code is embedded in HTML within a <SCRIPT> tag. Some old browsers don't understand this tag. To prevent them from treating your JavaScript as HTML, always use this trick involving HTML comments...
<script type="text/javascript">
<!-- hide JavaScript code from old browsers
YOUR SCRIPT HERE
// end the hiding comment -->
</script>
Here's an example of JavaScript code that prints current date in the top right corner of your Web page...
<html>
<head>
<script type="text/javascript">
<!--
function PrintDate() {
  today = new Date();
  document.write('Date: ', today.getMonth()+1, '/', today.getDate(), '/', today.getYear());
}
//-->
</script>
</head>

<body>
<p align="right">
<script type="text/javascript">
<!--
PrintDate();
//-->
</script>
</p>
THE REST OF YOUR PAGE.
</body>
</html>
See JavaScript Examples for more complex and useful examples of JavaScript code.

The power of JavaScript

JavaScript has one particular feature that makes it an interactive and power tool - event handling. You can trigger the JavaScript program by various events. For example, when the page loads, when it quits, when you pass your cursor over a link, or when you click on a button or a link.
Here's a list of the common event handlers, that all popular browsers can deal with...
EventWhen it's triggered
onAbortAn image is stopped from loading because the user either hits Stop or leaves the page.
onBlurAn element, such as a window, frame, or form field, loses focus; that is, when the user clicks on something else.
onClickThe user clicks on the particular element.
onChangeThe value of a form field changes, for example, when the user types in some data.
onDblClickThe user double-clicks on the particular element.
onErrorA loading error happens, like a missing image.
onFocusThe user puts the focus on the target element, by clicking on it or tabbing to it.
onKeyDownA key on the keyboard is pushed down, regardless of whether it's then held down or released.
onKeyPressThis event is repeatedly triggered as long as a key is held down.
onKeyUpA key on the keyboard is released.
onLoadThe browser completely loads the page.
onMouseDownA key on the mouse is pushed down, regardless of whether it's then held down or released.
onMouseMoveThe mouse moves.
onMouseOutThe pointer moves out of the target area.
onMouseOverThe pointer moves over the target element.
onMouseUpA key on the mouse is released.
onResetThe Reset button of a form is clicked.
onResizeA window or frame is resized by the user.
onSelectThe user highlights text in a form field.
onSubmitA form is submitted.
onUnloadThe user leaves the page.
The basic event handling syntax is very simple. The following JavaScript code will pop up a window when you click a button...
<form>
<input type="button" value="Click me" onClick="alert('This is JavaScript!');">
</form>
If you need an elaborate action to take place when the button is clicked, you can call a predefined function. The following JavaScript code writes text to the statusbar (the bar on the bottom of your browser where the URLs are shown)...
function MyFunc( txt ) {
   window.status = txt;
}
<form>
<input type="button" value="Click me" onClick="MyFunc('This is JavaScript!');">
</form>

Free JavaScript tutorials

There are a lot of free JavaScript help resources on the Net. Here are a few...
Webmonkey's JavaScript Tutorial
The author has been working with JavaScript since its invention, and he created this five-part JavaScript tutorial to teach you everything you need to know to begin your JavaScript career. The course comes complete with many exercises, and you'll be writing a script by the end of the first lesson.
Webmonkey's Advanced JavaScript Tutorial
In this free JavaScript tutorial the author introduces you to some of the fancier aspects of this language and the tips and lowdown that will allow you to build real multimedia applications.
HTML Goodies JavaScript Primers
30 lessons that get you started writing your own JavaScript events. Each of these 30 primers will display one JavaScript and tear it apart so you can see how it works. You'll be taught why something works, not just shown that it works.
The JavaScript Source
This is an excellent free JavaScript tutorial with tons of free "cut and paste" JavaScript code examples for your Web pages.

JavaScript is very rich, and although you can learn most of its grammar with these online tutorials, you won't learn the entire language. If you're serious about writing your own JavaScript codes, you need a good book...
The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks
by Cameron Adams and James Edwards
This book provides you with over 100 thoroughly-tested, customizable and elegant solutions that will show you how to add usable and accessible interactivity to your site: from slick drop-down menus, to style sheet switchers, to AJAX applications, and much more. It also includes download access to all JavaScript code samples used throughout the book - you can plug them right into your own websites without any retyping.

Crystal Reports in .NET

To follow this article, first create a Windows application by selecting File->New->Project->Visual C# Projects->Windows Application template from Visual Studio .NET project templates. I give my project name IntroToCR.
Adding a Report to a Project
Crystal Report is a part of Add New Item templates available in Visual Studio. To add a report to the project, add a new item by Right Clicking on the project in Solution Explorer and selecting Add->Add New Item->Crystal Report as you can see in Figure 1. I change the name of the report to Customers because we will be displaying customers related information from Northwind database.
Now click the Open button.

Figure 1. Adding a Report to the Project
The next step is to select the report document type from Crystal Report Gallery. As you can see from Figure 2, Crystal Report Gallery provides three options Using the Report Expert, As a Blank Report, or From an Existing Report.
For our first application, lets keep all options as default. I will be discussing rest of the options in my following articles.

Figure 2. Selecting a report type.
By clicking the OK button adds Customers.rpt file to the project and launches Standard Report Expert wizard as you can see in Figure 3, where you can select a data source. The Standard Report Expert wizard has 8 different tabs. I will discuss these tabs in more details in my following articles. The main purpose of this article is to show you how to create your first report in a few simple and quick steps.

Figure 3. Standard Report Expert wizard
Adding a Data Source
Now our next step is to link a data source to the wizard. There are different ways to link a data source to the wizard. The simplest way is to click on the OLE DB(ADO) tree item in Figure 3.
Clicking on OLE DB(ADO) item launches OLE DB Provider dialog where you can select a data source as you can see in Figure 4.

Figure 4. OLE DB Provider dialog
Now on the OLE DB Provider, you can select a provider. I select Microsoft OLE DB Provider for SQL Server. If you do not have access to SQL Server, you can select Access or other data providers.
After select Microsoft OLD DB Provider for SQL Server, you will see the Next button is activated on the wizard.
The Next button allows you to provide the connection information about a data source. As you can see in Figure 5, we select Northwind database.

Figure 5. Connection Information dialog
Now you can click the Finish button.
This option adds the Northwind database to the list and if you expand the database item, you will see the database tables.
Now on this page, I select Customers table and add it by clicking Insert Table button. Now you can see the table listed in the right list box. See Figure 6.

Figure 6. Northwind database tables
Now click on Next button which moves to the Fields tab. On this page, you can select what field you want to use in the report. For simplicity, I add only 5 columns to the report CustomerId, CompanyName, ContactName, ContactTitle, and City. See Figure 7. On this page, you can change the heading of a column by selecting a column and changing its name in the Column Heading text box.

Figure 7. Adding columns to report
Now we can continue through different pages but we will stop here. Click Finish here. This option adds the report with all columns to the project. The final report file looks like Figure 8.

Figure 8. Customers.rpt
Adding a Crystal Report Viewer Control
Now our next step is to add Customers.rpt to the Form. For this, we need to make sure the size of the Form is big enough to fit the report. So you may want to go ahead and modify the size of Form.
After resizing the Form, we need to add Crystal Report Viewer from Toolbox to the Form. Simply drag the Crystal Report Viewer control from Toolbox to the Form and resize it accordingly. My final Form looks like Figure 9.

Figure 9. Form with Crystal Report Viewer
Attaching Report to Crystal Report Viewer Control
The last step is to attach Customers.rpt to Crystal Report Viewer control. For this, we need to set the ReportSource property of Crystal Report Viewer control. On the Forms load event handler, we create an Instance of Customers class, and set it as the ReportSource property of Crystal Report Viewer control.
Just write the following two bold lines on your Forms load event handler.
private void Form1_Load(object sender, System.EventArgs e)
{
Customers custReport =
new Customers();
crystalReportViewer1.ReportSource = custReport;
}
Now compile and run the project. The output looks like Figure 10. Now you can see the report with data. With the help of Crystal Report Viewer, you can select from various options such as zoom in, zoom out, print, move next, move last, move previous, and move first.

Figure 10. The final report
Conclusion
By adding Crystal Report support to Visual Studio .NET, Microsoft had made developers like easier. In this article, we saw how easy it is to generate a report from a SQL Server database using Crystal Report available in Visual Studio 2003.
In my next articles in this series, I will be exploring more options of Crystal Reports.
Note: To run the attached source code, you MUST change the database information.

ASP.NET Page Life Cycle

Introduction

This article describes the life cycle of the page from the moment the URL is hit from the web browser till the HTML code is generated and sent to the web browser. Let us start by looking at some keywords that are involved in the life cycle of the page.
Background

IIS: IIS (Internet Information Server) is a complete Web server that makes it possible to quickly and easily deploy powerful Web sites and applications. It is the default web server used with .NET. When a Web server (for ASP.NET applications, typically IIS) receives a request, it examines the file-name extension of the requested file, determines which ISAPI extension should handle the request, and then passes the request to the appropriate ISAPI extension. (By default, ASP.NET handles file name extensions that have been mapped to it, such as .aspx, .ascx, .ashx, and .asmx.)

Note:

1. If a file name extension has not been mapped to ASP.NET, ASP.NET will not receive the request. It will be handled by the IIS. The requested page/image/file is returned without any processing.
2. If you create a custom handler to service a particular file name extension, you must map the extension to ASP.NET in IIS and also register the handler in your application's Web.config file.

ASPNET_ISAPI.DLL: This DLL is the ISAPI extension provided with ASP.NET to process the web page requests. IIS loads this DLL and sends the page request to this DLL. This DLL loads the HTTPRuntime for further processing.

ASPNET_WP.EXE: Each worker process (ASPNET_WP.EXE) contains an Application Pool. Each Application Pool can contain any number of Applications. Application Pool is also called as AppDomain. When a web page is requested, IIS looks for the application pool under which the current application is running and forwards the request to the respective worker process.

HTTP Pipeline: HTTP Pipeline is the general-purpose framework for server-side HTTP programming that serves as the foundation for ASP.NET pages as well as Web Services. All the stages involved from creating HTTP Runtime to HTTP Handler is called HTTP Pipeline.

HTTP Runtime: Each AppDomain has its own instance of the HttpRuntime class—the entry point in the pipeline. The HttpRuntime object initializes a number of internal objects that will help carry the request out. The HttpRuntime creates the context for the request and fills it up with any HTTP information specific to the request. The context is represented by an instance of the HttpContext class. Another helper object that gets created at such an early stage of the HTTP runtime setup is the text writer—to contain the response text for the browser. The text writer is an instance of the HttpWriter class and is the object that actually buffers any text programmatically sent out by the code in the page. Once the HTTP runtime is initialized, it finds an application object to fulfill the request. The HttpRuntime object examines the request and figures out which application it was sent to (from the pipeline's perspective, a virtual directory is an application).

HTTP Context: This is created by HTTP Runtime. The HttpContext class contains objects that are specific to the current page request, such as the HttpRequest and HttpResponse objects. You can use this class to share information between pages. It can be accessed with Page.Context property in the code.

HTTP Request: Provides access to the current page request, including the request headers, cookies, client certificate, query string, and so on. You can use this class to read what the browser has sent. It can be accessed with Page.Request property in the code.

HTTP Response: Provides access to the output stream for the current page. You can use this class to inject text into the page, to write cookies, and more. It can be accessed with Page.Response property in the code.

HTTP Application: An application object is an instance of the HttpApplication class—the class behind the global.asax file. HTTPRuntime uses HttpApplicationFactory to create the HTTPApplication object. The main task accomplished by the HTTP application manager is finding out the class that will actually handle the request. When the request is for an .aspx resource, the handler is a page handler—namely, an instance of a class that inherits from Page. The association between types of resources and types of handlers is stored in the configuration file of the application. More exactly, the default set of mappings is defined in the section of the machine.config file. However, the application can customize the list of its own HTTP handlers in the local web.config file. The line below illustrates the code that defines the HTTP handler for .aspx resources.
Collapse



HttpApplicationFactory: Its main task consists of using the URL information to find a match between the virtual directory of the URL and a pooled HttpApplication object.

HTTP Module: An HTTP module is an assembly that is called on every request that is made to your application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules let you examine incoming and outgoing requests and take action based on the request. They also let you examine the outgoing response and modify it. ASP.NET uses modules to implement various application features, which include forms authentication, caching, session state, and client script services. In each case, when those services are enabled, the module is called as part of a request and performs tasks that are outside the scope of any single page request. Modules can consume application events and can raise events that can be handled in the Global.asax file.

HTTP Handler: An ASP.NET HTTP handler is the process that runs in response to a request that is made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request a .aspx file, the request is processed by the page handler. We can write our own handler and handler factory if we want to handle the page request in a different manner.

Note: HTTP modules differ from HTTP handlers. An HTTP handler returns a response to a request that is identified by a file name extension or family of file name extensions. In contrast, an HTTP module is invoked for all requests and responses. It subscribes to event notifications in the request pipeline and lets you run code in registered event handlers. The tasks that a module is used for are general to an application and to all requests for resources in the application.
Life Cycle of Page

1. Web page request comes from browser.
2. IIS maps the ASP.NET file extensions to ASPNET_ISAPI.DLL, an ISAPI extension provided with ASP.NET.
3. ASPNET_ISAPI.DLL forwards the request to the ASP.NET worker process (ASPNET_WP.EXE or W3P.EXE).
4. ISAPI loads HTTPRuntime and passes the request to it. Thus, HTTP Pipelining has begun.
5. HTTPRuntime uses HttpApplicationFactory to either create or reuse the HTTPApplication object.
6. HTTPRuntime creates HTTPContext for the current request. HTTPContext internally maintains HTTPRequest and HTTPResponse.
7. HTTPRuntime also maps the HTTPContext to the HTTPApplication which handles the application level events.
8. HTTPApplication runs the HTTPModules for the page requests.
9. HTTPApplication creates HTTPHandler for the page request. This is the last stage of HTTPipelining.
10. HTTPHandlers are responsible to process request and generate corresponding response messages.
11. Once the request leaves the HTTPPipeline, page level events begin.
12. Page Events are as follows: PreInit, Init, InitComplete, PreLoad, Load, Control events (Postback events), Load Complete, PreRender, SaveStateComplete, Render and Unload.
13. HTTPHandler generates the response with the above events and sends back to the IIS which in turn sends the response to the client browser.

Page_Life_cycle.gif HTTP_Pipeline.gif

Events in the Life Cycle of Page

PreInit: All the Pre and Post events are introduced as part of .NET Framework 2.0. As the name suggests, this event is fired before the Init method is fired. Most common functionalities implemented in this method include:

1. Check the IsPostBack property
2. Set the master page dynamically
3. Set the theme property of the page dynamically
4. Read or Set the profile property values
5. Re-create the dynamic controls

Init: This event is raised after all controls in the page are initialized and any skin settings have been applied. This event is used to read or initialize control properties. It can be used to register events for some controls for which the events are not specified in the aspx page.
Ex: OnClick event of the Button can be registered in the Init rather than specifying in the OnClick property of the Button in the aspx page.

InitComplete: Use this event for processing tasks that require all initialization to be complete.

PreLoad: Use this event if you need to perform processing on your page or control before the Load event. After the Page raises this event, it loads view state for itself and all controls, and then processes any postback data included with the Request instance.

Load: The Page calls the OnLoad event method on the Page, then recursively does the same for each child control, which does the same for each of its child controls until the page and all controls are loaded. Use the OnLoad event method to set properties in controls and 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: Use this event for tasks that require that all other controls on the page be loaded.

PreRender: This is the last event raised before the HTML code is generated for the page. The PreRender event also occurs for each control on the page. Use the event to make final changes to the contents of the page or its controls.

SaveStateComplete: Before this event occurs, ViewState has been saved for the page and for all controls. Any changes to the page or controls at this point will be ignored.
Use this event to perform tasks that require view state to be saved, but that do not make any changes to controls.

Render: This is the stage where the HTML code for the page is rendered. The Page object calls the Render method of each control at this stage. All ASP.NET Web server controls have a Render method that writes out the control's markup that is sent to the browser.

UnLoad: This event occurs 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.
For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks.

ADO.NET 3.5 Briefly

ADO .NET
Most applications need data access at one point of time making it a crucial component when working with applications. Data access is making the application interact with a database, where all the data is stored. Different applications have different requirements for database access. VB .NET uses ADO .NET (Active X Data Object) as it's data access and manipulation protocol which also enables us to work with data on the Internet. Let's take a look why ADO .NET came into picture replacing ADO.
Evolution of ADO.NET
The first data access model, DAO (data access model) was created for local databases with the built-in Jet engine which had performance and functionality issues. Next came RDO (Remote Data Object) and ADO (Active Data Object) which were designed for Client Server architectures but, soon ADO took over RDO. ADO was a good architecture but as the language changes so is the technology. With ADO, all the data is contained in a recordset object which had problems when implemented on the network and penetrating firewalls. ADO was a connected data access, which means that when a connection to the database is established the connection remains open until the application is closed. Leaving the connection open for the lifetime of the application raises concerns about database security and network traffic. Also, as databases are becoming increasingly important and as they are serving more people, a connected data access model makes us think about its productivity. For example, an application with connected data access may do well when connected to two clients, the same may do poorly when connected to 10 and might be unusable when connected to 100 or more. Also, open database connections use system resources to a maximum extent making the system performance less effective.
Why ADO.NET?
To cope up with some of the problems mentioned above, ADO .NET came into existence. ADO .NET addresses the above mentioned problems by maintaining a disconnected database access model which means, when an application interacts with the database, the connection is opened to serve the request of the application and is closed as soon as the request is completed. Likewise, if a database is Updated, the connection is opened long enough to complete the Update operation and is closed. By keeping connections open for only a minimum period of time, ADO .NET conserves system resources and provides maximum security for databases and also has less impact on system performance. Also, ADO .NET when interacting with the database uses XML and converts all the data into XML format for database related operations making them more efficient.

The ADO.NET Data Architecture
Data Access in ADO.NET relies on two components: DataSet and Data Provider.

DataSet
The dataset is a disconnected, in-memory representation of data. It can be considered as a local copy of the relevant portions of the database. The DataSet is persisted in memory and the data in it can be manipulated and updated independent of the database. When the use of this DataSet is finished, changes can be made back to the central database for updating. The data in DataSet can be loaded from any valid data source like Microsoft SQL server database, an Oracle database or from a Microsoft Access database.
Data Provider
The Data Provider is responsible for providing and maintaining the connection to the database. A DataProvider is a set of related components that work together to provide data in an efficient and performance driven manner. The .NET Framework currently comes with two DataProviders: the SQL Data Provider which is designed only to work with Microsoft's SQL Server 7.0 or later and the OleDb DataProvider which allows us to connect to other types of databases like Access and Oracle. Each DataProvider consists of the following component classes:
The Connection object which provides a connection to the database
The Command object which is used to execute a command
The DataReader object which provides a forward-only, read only, connected recordset
The DataAdapter object which populates a disconnected DataSet with data and performs update
Data access with ADO.NET can be summarized as follows:
A connection object establishes the connection for the application with the database. The command object provides direct execution of the command to the database. If the command returns more than a single value, the command object returns a DataReader to provide the data. Alternatively, the DataAdapter can be used to fill the Dataset object. The database can be updated using the command object or the DataAdapter.
Component classes that make up the Data Providers
The Connection Object
The Connection object creates the connection to the database. Microsoft Visual Studio .NET provides two types of Connection classes: the SqlConnection object, which is designed specifically to connect to Microsoft SQL Server 7.0 or later, and the OleDbConnection object, which can provide connections to a wide range of database types like Microsoft Access and Oracle. The Connection object contains all of the information required to open a connection to the database.

The Command Object
The Command object is represented by two corresponding classes: SqlCommand and OleDbCommand. Command objects are used to execute commands to a database across a data connection. The Command objects can be used to execute stored procedures on the database, SQL commands, or return complete tables directly. Command objects provide three methods that are used to execute commands on the database:
ExecuteNonQuery: Executes commands that have no return values such as INSERT, UPDATE or DELETE
ExecuteScalar: Returns a single value from a database query
ExecuteReader: Returns a result set by way of a DataReader object
The DataReader Object
The DataReader object provides a forward-only, read-only, connected stream recordset from a database. Unlike other components of the Data Provider, DataReader objects cannot be directly instantiated. Rather, the DataReader is returned as the result of the Command object's ExecuteReader method. The SqlCommand.ExecuteReader method returns a SqlDataReader object, and the OleDbCommand.ExecuteReader method returns an OleDbDataReader object. The DataReader can provide rows of data directly to application logic when you do not need to keep the data cached in memory. Because only one row is in memory at a time, the DataReader provides the lowest overhead in terms of system performance but requires the exclusive use of an open Connection object for the lifetime of the DataReader.
The DataAdapter Object
The DataAdapter is the class at the core of ADO .NET's disconnected data access. It is essentially the middleman facilitating all communication between the database and a DataSet. The DataAdapter is used either to fill a DataTable or DataSet with data from the database with it's Fill method. After the memory-resident data has been manipulated, the DataAdapter can commit the changes to the database by calling the Update method. The DataAdapter provides four properties that represent database commands:
SelectCommand
InsertCommand
DeleteCommand
UpdateCommand
When the Update method is called, changes in the DataSet are copied back to the database and the appropriate InsertCommand, DeleteCommand, or UpdateCommand is executed.

State Management Briefly

Web pages rarely be stand alone. Web applications almost always need to track users who visits multiple pages, whether to provide personalization, store information about a user or to track usage for reporting purposes.

Purpose

State management is the process by which you maintain state and page information over multiple requests for the same or different pages.


Types of State Management

There are 2 types State Management:

1. Client – Side State Management
This stores information on the client's computer by embedding the information into a Web page, a uniform resource locator(url), or a cookie. The techniques available to store the state information at the client end are listed down below:

a. View State – Asp.Net uses View State to track the values in the Controls. You can add custom values to the view state. It is used by the Asp.net page framework to automatically save the values of the page and of each control just prior to rendering to the page. When the page is posted, one of the first tasks performed by page processing is to restore view state.

b. Control State – If you create a custom control that requires view state to work properly, you should use control state to ensure other developers don’t break your control by disabling view state.

c. Hidden fields – Like view state, hidden fields store data in an HTML form without displaying it in the user's browser. The data is available only when the form is processed.

d. Cookies – Cookies store a value in the user's browser that the browser sends with every page request to the same server. Cookies are the best way to store state data that must be available for multiple Web pages on a web site.

e. Query Strings - Query strings store values in the URL that are visible to the user. Use query strings when you want a user to be able to e-mail or instant message state data with a URL.

2. Server – Side State Management
a. Application State - Application State information is available to all pages, regardless of which user requests a page.

b. Session State – Session State information is available to all pages opened by a user during a single visit.

Both application state and session state information is lost when the application restarts. To persist user data between application restarts, you can store it using profile properties.

Implementation Procedure


Client – Side State Management:

View State:
The ViewState property provides a dictionary object for retaining values between multiple requests for the same page. When an ASP.NET 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. If the data is too long for a single field, then ASP.NET performs view state chunking (new in ASP.NET 2.0) to split it across multiple hidden fields. The following code sample demonstrates how view state adds data as a hidden form within a Web page’s HTML:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE” value="/wEPDwUKMTIxNDIyOTM0Mg9kFgICAw9kFgICAQ8PFgIeBFRleHQFEzQvNS8yMDA2IDE6Mzc6MTEgUE1kZGROWHn/rt75XF/pMGnqjqHlH66cdw==" />


Encrypting of the View State: You can enable view state encryption to make it more difficult for attackers and malicious users to directly read view state information. Though this adds processing overhead to the Web server, it supports in storing confidential information in view state. To configure view state encryption for an application does the following:

<Configuration>

    <system.web> 

  <pages viewStateEncryptionMode="Always"/> 

   </system.web> 

</configuration>


Alternatively, you can enable view state encryption for a specific page by setting the value in the page directive, as the following sample demonstrates:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ViewStateEncryptionMode="Always"%> 

View State is enabled by default, but if you can disable it by setting the EnableViewState property for each web control to false. This reduces the server processing time and decreases page size.
Reading and Writing Custom View State Data:
If you have a value that you’d like to keep track of while the user is visiting a single ASP.NET Web page, adding a custom value to ViewState is the most efficient and secure way to do that. However, ViewState is lost if the user visits a different Web page, so it is useful only for temporarily storing values.
Example: Determine the time of last visit to the page

// Check if View State object exists, and display it if it does

If (ViewState ["lastVisit"]!= null) 

Label1.Text = (string)ViewState["lastVisit"]; else 

Label1.Text = "lastVisit ViewState not defined."; 

// Define the ViewState object for the next page view ViewState.Add("lastVisit", DateTime.Now.ToString()); 




Control State: If you create a custom control that requires ViewState, you can use the ControlState property to store state information for your control. ControlState allows you to persist property information that is specific to a control and cannot be turned off like the ViewState property. To use control state in a custom control, your control must override the OnInit method and call the Register-RequiresControlState method during initialization and then override the SaveControl-State and LoadControlState methods.

Hidden fields: ViewState stores information in the Web page using hidden fields. Hidden fields are sent back to the server when the user submits a form; however, the information is never displayed by the Web browser (unless the user chooses to view the page source). ASP.NET allows you to create your own custom hidden fields and store values that are submitted with other form data. A HiddenField control stores a single variable in its Value property and must be explicitly added to the page. You can use hidden fields only to store information for a single page, so it is not useful for storing session data. If you use hidden fields, you must submit your pages to the server using Hypertext Transfer Protocol (HTTP) POST (which happens if the user presses a button) rather than requesting the page using HTTP GET (which happens if the user clicks a link). Unlike view state data, hidden fields have no built-in compression, encryption, hashing, or chunking, so users can view or modify data stored in hidden fields.

Cookies: Web applications can store small pieces of data in the client’s Web browser by using cookies. A cookie is a small amount of data that is stored either in a text file on the client file system (if the cookie is persistent) or in memory in the client browser session (if the cookie is temporary). The most common use of cookies is to identify a single user as he or she visits multiple Web pages.

Reading and Writing Cookies:
A Web application creates a cookie by sending it to the client as a header in an HTTP response. The Web browser then submits the same cookie to the server with every new request.
Create a cookie -> add a value to the Response.Cookies HttpCookieCollection.
Read a cookie -> read values in Request.Cookies.
Example:
// Check if cookie exists, and display it if it does 

if (Request.Cookies["lastVisit"] != null) // Encode the cookie in case the cookie contains client-side script Label1.Text = Server.HtmlEncode(Request.Cookies["lastVisit"].Value); 

else Label1.Text = "No value defined"; 

// Define the cookie for the next visit Response.Cookies["lastVisit"].Value = DateTime.Now.ToString();Response.Cookies["lastVisit"].Expires = DateTime.Now.AddDays(1); 


If you do not define the Expires property, the browser stores it in memory and the cookie is lost if the user closes his or her browser.

To delete a cookie, overwrite the cookie and set an expiration date in the past. You can’t directly delete cookies because they are stored on the client’s computer.
Controlling the Cookie Scope: By default, browsers won’t send a cookie to a Web site with a different hostname. You can control a cookie’s scope to either limit the scope to a specific folder on the Web server or expand the scope to any server in a domain. To limit the scope of a cookie to a folder, set the Path property, as the following example demonstrates:

Example:
Response.Cookies["lastVisit"].Path = "/Application1"; 


Through this the scope is limited to the “/Application1” folder that is the browser submits the cookie to any page with in this folder and not to pages in other folders even if the folder is in the same server. We can expand the scope to a particular domain using the following statement:
Example:
Response.Cookies[“lastVisit”].Domain = “Contoso”;

Storing Multiple Values in a Cookie:
Though it depends on the browser, you typically can’t store more than 20 cookies per site, and each cookie can be a maximum of 4 KB in length. To work around the 20-cookie limit, you can store multiple values in a cookie, as the following code demonstrates:
Example:

Response.Cookies["info"]["visit"].Value = DateTime.Now.ToString();

Response.Cookies["info"]["firstName"].Value = "Tony";

Response.Cookies["info"]["border"].Value = "blue";

Response.Cookies["info"].Expires = DateTime.Now.AddDays(1);


Running the code in this example sends a cookie with the following value to the Web browser:
(visit=4/5/2006 2:35:18 PM) (firstName=Tony) (border=blue)

Query Strings: Query strings are commonly used to store variables that identify specific pages, such as search terms or page numbers. A query string is information that is appended to the end of a page URL. A typical query string might look like the following real-world example:
http://support.microsoft.com/Default.aspx?kbid=315233
In this example, the URL identifies the Default.aspx page. The query string (which starts with a question mark [?]) contains a single parameter named “kbid,” and a value for that parameter, “315233.” Query strings can also have multiple parameters, such as the following real-world URL, which specifies a language and query when searching the Microsoft.com Web site:
http://search.microsoft.com/results.aspx?mkt=en-US&setlang=en-US&q=hello+world

Value Name | ASP.NET Object | Value
mkt | Request.QueryString[“mkt”] | en-US
setlang | Request.QueryString[“setlang”] | en-US
q | Request.QueryString[“q”] | hello world

Limitations for Query Strings:
1. Some Browsers and client devices impose a 2083 – character limit on the length of the URL.
2. You must submit the page using an HTTP GET command in order for query string values to be available during page processing. Therefore, you shouldn’t add query strings to button targets in forms.
3. You must manually add query string values to every hyperlink that the user might click.
Example:
Label1.Text = "User: " + Server.HtmlEncode(Request.QueryString["user"]) + 

", Prefs: " + Server.HtmlEncode(Request.QueryString["prefs"]) + 

", Page: " + Server.HtmlEncode(Request.QueryString["page"]); 


Server - Side State Management:

Application State: ASP.NET allows you to save values using application state, a global storage mechanism that is accessible from all pages in the Web application. Application state is stored in the Application key/value dictionary. Once you add your application-specific information to application state, the server manages it, and it is never exposed to the client. Application state is a great place to store information that is not user-specific. By storing it in the application state, all pages can access data from a single location in memory, rather than keeping separate copies of the data. Data stored in the Application object is not permanent and is lost any time the application is restarted.

ASP.NET provides three events that enable you to initialize Application variables (free resources when the application shuts down) and respond to Application errors:

a. Application_Start: Raised when the application starts. This is the perfect place to initialize Application variables.

b. Application_End: Raised when an application shuts down. Use this to free application resources and perform logging.

c. Application_Error: Raised when an unhandled error occurs. Use this to perform error logging.


Session State: ASP.NET allows you to save values using session state, a storage mechanism that is accessible from all pages requested by a single Web browser session. Therefore, you can use session state to store user-specific information. Session state is similar to application state, except that it is scoped to the current browser session. If different users are using your application, each user session has a different session state. In addition, if a user leaves your application and then returns later after the session timeout period, session state information is lost and a new session is created for the user. Session state is stored in the Session key/value dictionary.

You can use session state to accomplish the following tasks:
i. Uniquely identify browser or client-device requests and map them to individual session instances on the server. This allows you to track which pages a user saw on your site during a specific visit.

ii. Store session-specific data on the server for use across multiple browser or client-device requests during the same session. This is perfect for storing shopping cart information.

iii. Raise appropriate session management events. In addition, you can write application code leveraging these events.

ASP.NET session state supports several different storage options for session data:

a. InProc Stores session state in memory on the Web server. This is the default, and it offers much better performance than using the ASP.NET state service or storing state information in a database server. InProc is fine for simple applications, but robust applications that use multiple Web servers or must persist session data between application restarts should use State Server or SQLServer.

b. StateServer Stores session state in a service called the ASP.NET State Service. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm. ASP.NET State Service is included with any computer set up to run ASP.NET Web applications; however, the service is set up to start manually by default. Therefore, when configuring the ASP.NET State Service, you must set the startup type to Automatic.

c. SQLServer Stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm. On the same hardware, the ASP.NET State Service outperforms SQLServer. However, a SQL Server database offers more robust data integrity and reporting capabilities.

d. Custom Enables you to specify a custom storage provider. You also need to implement the custom storage provider.

e. Off Disables session state. You should disable session state if you are not using it to improve performance.

Advantages


Advantages of Client – Side State Management:

1. Better Scalability: With server-side state management, each client that connects to the Web server consumes memory on the Web server. If a Web site has hundreds or thousands of simultaneous users, the memory consumed by storing state management information can become a limiting factor. Pushing this burden to the clients removes that potential bottleneck.

2. Supports multiple Web servers: With client-side state management, you can distribute incoming requests across multiple Web servers with no changes to your application because the client provides all the information the Web server needs to process the request. With server-side state management, if a client switches servers in the middle of the session, the new server does not necessarily have access to the client’s state information. You can use multiple servers with server-side state management, but you need either intelligent load-balancing (to always forward requests from a client to the same server) or centralized state management (where state is stored in a central database that all Web servers access).

Advantages of Server – Side State Management:

1. Better security: Client-side state management information can be captured (either in transit or while it is stored on the client) or maliciously modified. Therefore, you should never use client-side state management to store confidential information, such as a password, authorization level, or authentication status.

2. Reduced bandwidth: If you store large amounts of state management information, sending that information back and forth to the client can increase bandwidth utilization and page load times, potentially increasing your costs and reducing scalability. The increased bandwidth usage affects mobile clients most of all, because they often have very slow connections. Instead, you should store large amounts of state management data (say, more than 1 KB) on the server.

Dot.Net Interview Quations in TCS Part-2

42)How to register strong name with my class library?
Ans:that just means tha the referenced assembly ApplicationDataAccess is not
signed so it doesn't have a strong name.
Since you signed your application/assembly all referenced assemblies must
also be signed.
..................................................................................................................................
43)Can i register my assembly in gac with out strong name?
Ans:
Refer:"http://www.dotnetspider.com/forum/262111-Interviiew-questions-related-assembly-plz-any-one-answer.aspx"
.........................................................................................................................................
44)What is dataset?
Ans:
A Dataset is a in memory representation of a collection of
Database objects including tables of a relational database
scheme. The dataset contains a collection of Tables,
Relations, constraints etc.,

It can be used for manipulating the data remotely and
finally updating the database with the modified data. This
way it enables disconnected means of working with data. This
improves performance
in terms of reducing the number of times a database is
accessed for data manipulations.

The dataset contains all the objects as a Collection of
objects. For example it contains the Database Tables as
DataTable objects. The data from the database is filled into
the dataset by using the DataAdapter.
...................................................................
45)Diff between dataset and datareder?
Ans: Data Reader

A DataReader is a 
read-only stream of data returned from the database as the query 
executes. It only contains one row of data in memory at a time and is 
restricted to navigating forward only in the results one record at a 
time. The DataReader does support access to multiple result sets, but 
only one at a time and in the order retrieved. Just as in the original 
version of ADO, the data is no longer available through the DataReader 
once the connection to the data source is closed, which means a 
DataReader requires a connection to the database throughout its usage. 
Output parameters or return values are only available through the 
DataReader once the connection is closed.

DataReaders all 
implement the same IDataReader interface, which means that all of the 
DataReaders should provide the same set of functionality. Each 
DataReader implementation is optimized for a specific data provider such
 as SQL Server or Oracle. Version 1.0 of the Microsoft .NET Framework 
includes a System.Data.SqlClient.SqlDataReader that is specific to SQL 
Server and a System.Data.OleDb.OleDbDataReader that is more generic for 
OLEDB providers. Version 1.1 of the .NET Framework introduced the 
SqlCeDataReader for connecting to the SQL Server edition for Windows CE,
 OdbcDataReader for ODBC data sources, and OracleDataReader for 
connecting to Oracle databases. It isn''t required that you use the 
DataReaders from Microsoft, and each database vendor often has its own 
.NET provider. In addition, you can implement a DataReader of your own 
through the IDataReader interface.

What is a DataSet?
DataSet 
is the core of the ADO.NET disconnected architecture and is used to 
store data in a disconnected state. It was designed to fully support the
 use of XML so an XML document can be read into a DataSet or a DataSet 
can be exported to XML. This allows a DataSet to be easily transported 
across a network so it can be used as a return from a Web service or 
other type of remote call. Changes to a DataSet can be propagated back 
to the data source from where the data originated. A DataSet is fully 
navigable forward or backward and the contents can be filtered, sorted, 
or searched as desired, making all records accessible at any given 
point.

The DataSet, part of the System.Data namespace, is not 
specific to any one data provider, but rather is independent of them. A 
DataSet relies on a DataAdapter specific to each provider to be the 
intermediary between the DataSet and the data store. The DataAdapter 
uses a DataReader for the specific provider to fill the contents of the 
DataSet.

You can use the following information to help you decide which data retrieval is right for your purposes.

When to consider using a DataReader:
•The
 DataReader is a better choice for applications that require optimized 
read-only and forward-only access to data such as binding to a DataGrid 
control. The sooner the data is off-loaded from the DataReader and the 
connection is closed the better the application performance. 
•The 
DataReader is a better choice when you are planning to make repeated 
calls to retrieve small amounts of information or the data you are 
retrieving must be as up to date as possible each time it is used.

When to consider using a DataSet:
•The
 DataSet is a better choice for applications that will not off-load the 
query result immediately, or when there is extensive processing such as 
complex business logic involved between data accesses. The DataSet will 
retrieve the data, off-load the data into memory and return the database
 connection to the connection pool, where as a DataReader would keep the
 connection locked open until processing is complete. This could easily 
cause a high traffic application to run out of available database 
connections. 
•The DataSet is a better choice when you need to 
navigate through the data more than once. For example, if you have 
multiple controls you need to build off the same data, then a DataSet is
 the better answer because a DataReader can only be read once so it can 
only be bound to a single control and would require the data to be 
retrieved for use with each control. 
•The DataSet is a better choice
 when the data does not change frequently enough to warrant always 
retrieving it from the database or is specific to the user requesting 
the data. A DataSet can be stored in Session or Application variables or
 cached through the System.Web.Caching.Cache class to improve 
application performance by not having to retrieve the data from the 
database each time it is needed. 
•The DataSet is a better choice 
when building a Web service that will return the retrieved data. Since a
 DataSet is serializable it can serve as the return value. Since a 
DataReader requires a persistent database connection, it cannot be used 
as a return type from a Web service.
................................................................................................................................
46)How can we made changes in database?
Ans: 
da.update()
..............................................................................................................................
47)One user changed one record in dataset and updated in
database but at same time another user also changed the same
record in his dataset and try nto update in database so is
the change is accepted in database or rejected? 
Ans: 
he
said no
...................................................................
48)Where dataset will store?
Ans:
Does dataset store all its datatables' records into server memory if I just call one datatable from it
Lets make an example, a dataset with three datatables - tbCompany, tbCompanyStaffs, tbSalesOrder
where tbCompany is the parent of tbCompanyStaffs. tbSalesOrder is an independant table.
Does dataset load all tbCompanyStaffs records into the server memory as well when a class retrive data from tbCompany?
.......................................................................................................................................................
49)What is heap memory?
Ans: On the other hand, heap is an area of memory used for dynamic memory allocation. Blocks of memory are allocated and freed in this case in an arbitrary order. The pattern of allocation and size of blocks is not known until run time. Heap is usually being used by a program for many different purposes.
................................................................................................................................................................
50)What is stack memory?
Ans:
The two sections other from the code segment in the memory are used for data. The stack is the section of memory that is allocated for automatic variables within functions.

Data is stored in stack using the Last In First Out (LIFO) method. This means that storage in the memory is allocated and deallocated at only one end of the memory called the top of the stack. Stack is a section of memory and its associated registers that is used for temporary storage of information in which the most recently stored item is the first to be retrieved.


Visit:"http://www.c-sharpcorner.com/uploadfile/rmcochran/csharp_memory01122006130034pm/csharp_memory.aspx?articleid=9adb0e3c-b3f6-40b5-98b5-413b6d348b91"
...............................................................................................................................................
51)When heap memory will create?
Ans:heap is the section of computer memory where all the variables
created or initialized at runtime are stored.

..........................................................................................................................................
52)When stack memory will create?
 Ans:stack is a place in the computer memory where all the variables that are declared and initialized before runtime are stored.
 ...........................................................................................................................................
53) If heap memory is full what happens? (how much memory it
extends? Or it uses the stack memory)
 Ans:Destroy Unwanted memory
........................................................................................................ 
54)If stack memory also full what happen?
Ans:
.......................................................................................................................
55)What is constructor?
 
Ans: A constructor is a special method for initializing a new instance of a class.The constructor method for a class will have the same name as the class.
 ...............................................................................
 56)Why we use constructor?
Ans:Initialization
 of values of different variables is critical in any application 
development. C# does initialize simple data-types to default values as 
per the language specification in the .Net framework, but for classes 
that are user specific, it is obvious that you would be the only one who
 can decide what is an ideal default value. The means of achieving this 
is Constructors. There is also a perception that constructors can only 
be used beyond initialization, which is true to some extent. We will 
examine them in the following sections.
.................................................................
57)What is destructor?
Ans: Destructors are used to release any resources allocated by the object.  E.g.,
class Lock might lock a semaphore, and the destructor will release
that semaphore.  The most common example is when the constructor uses new,
and the destructor uses delete.
refer:"http://sawaal.ibibo.com/computers-and-technology/what-destructor-469845.html"
...................................................................................
58)Why we use destructor?
Ans:Destructor main advantage is Clean unwanted resources
..................................................................................
60)Garbage collector?
Ans:In computer science, garbage collection (GC) is a form of automatic memory management. It is a special case of resource management
in which the limited resource being managed is memory. The garbage collector, or just collector, attempts to reclaim garbage
or memory occupied by objects that are no longer in use by the program.
..............................................................................
61)What is dispose?
Ans:
The Dispose method in .NET belongs to IDisposable interface 
and it is best used to release unmanaged objects like File 
objects, Windows API objects, Database connection objects, 
COM objects etc from the memory. Its performance is better 
than the finalize() method. 
............................................................
62) What is difference between dispose and close?
 
 Ans:
There is one major difference between
 calling the Close and Dispose methods on database connections. Close 
leaves the connection in a closed state; but, it is reusable—all 
properties, etc. can be accessed and Open can be called. On the other 
hand, after calling Dispose on a database connection—as with any 
object—, the connection object can no longer be accessed. 

However, calling Dispose does not remove the connection from the connection pool. 

[edit]Visual C# Best Practice
Only
 call the Close method on a Stream or a database connection if the 
object will be reused. Otherwise, use the Dispose method. 

The 
Dispose method may be called on any instance of any type implementing 
the IDisposable interface. This is supported by the C# using statement 
which makes calling Dispose automatically easy. 

Retrieved from "http://en.csharp-online.net/CSharp_FAQ:_What_is_the_difference_between_Close_and_Dispose" 
 
 ..........................................................................................
63)What is finalize?
Ans: 
 Method called automatically when an object is destroyed by the garbage collector. Finalize
 is useful for releasing unmanaged resources acquired by the object 
before the object is garbage collected. Managed resources do not require
 a  Finalize method; because, they will be released automatically by the garbage collector. Destructors defined in C# classes are mapped to Finalize methods. Also known as a finalizer
 .....................................................................................
64)How to remove the object reference?
Ans: passing null
value
..........................................................
65)What is final key word? 
Ans: 
 
..........................................................
66)What is autopostback?
Ans:The data is executed on server side
........................................................
67)What is dataview? Usage?
 Ans:
You have a DataTable in your program and want to use a DataView 
to selectively filter and sort the rows. The DataView class in 
System.Data is ideal for sorting data for UIs or for database INSERT. 
Here we look at ways you can utilize the data in your DataTable by 
sorting it with DataView. 
REfer:"http://dotnetperls.com/dataview"
......................................................................
68)What is caching?
Ans: this technique can be used to temporarily store page output or 
application data either on the client or on the server, which can then 
be re-used to satisfy subsequent requests and thus avoid the overhead of
 re-creating the same information. 
Caching is particularly suitable when you expect to return the same information in the same format for many different requests.
........................................................................................................
69)How to expire my cache?
Ans:
using duration in page
directive
.............................................................
70)If i store cache in server the server will over load
because of cache objects so how can i prevent that? 
Ans: 
using downstream caching eg: net provider serve and local
system cache
...................................................................
71)What is data cache?
Ans:
.......................................................................
72)How can i get the value from cache?
Ans:
...........................................................
73)If i want insert record in database tell me the steps?
Ans:
Open Sql database Write insert querry
..........................................................]
74)Diff between authentication and authorization?
Ans:
Authentication:
 The process of determining the identity of a user. In effect, 
authentication validates that the user is who he or she claims to be.

Authorization:
 The process of granting access privileges to resources or tasks within 
an application. Applications typically authenticate users and then 
authorize them based on their identities or roles within an 
organization.............................................................................
75)How to authenticate user in asp.net?
Ans:
ASP.NET supports three types of authentication methods. These are 
1.Windows-based authentication
2.Forms-based authentication
3.Microsoft Passport authentication
...........................................................................................................................
76)Types of authorizations?
Ans:
There are two forms of authorization available in ASP.NET:
  • FileAuthorization - relies on NTFS file permissions for granting access.
  • UrlAuthorization - in the Web.config file you can specify the authorization rules for various directories or files using the <authorization> element.
 .....................................................................
77)Explain the three types of authorizations?
Ans:
.......................................................................
78)How iis uses the windows authentication?
Ans:
With Windows-based authentication, the ASP.NET Web application relies on the Windows operating system to authenticate the user. ASP.NET uses Windows-based authentication in conjunction with IIS authentication.
With Windows-based authentication, the user requests a secure Web page from the Web application, and the request then goes through IIS. If the user’s credentials do not match those of an authorized user, IIS rejects the request. The user then has to enter his or her name and password into the logon form. The credentials are again verified by IIS. If correct, IIS directs the original request to the Web application. The secure Web page is then returned to the user
........ ...................................................................................
79)What is forms authentication?
Ans:
Forms-based authentication refers to a 
system where non-authenticated requests are redirected to a Hypertext 
Markup Language (HTML) form by using Hypertext Transfer Protocol (HTTP) 
client-side redirection. The user provides credentials and submits the 
form. If the application validates the credentials on the form, the 
system issues an authentication cookie to the user. Subsequent requests 
from the user are issued with the authentication cookie in the request 
headers, and then the user is authenticated based on those request 
headers. 
................................................................
80)What is impersonation?
Ans:
At times users access a resource as though they were 
someone else. This is known as impersonation. For example, 
if a web page has no access controls, then any user can 
access that web page. HTML pages, ASP pages, and components 
in version 3.0 and earlier can be accessed through two 
accounts named IUSR_machinename and IWAM_machinename. Both 
the accounts are set up during IIS installation, and are 
automatically added to all the folders in every web site on 
the server.

Anonymous access to a resource in IIS makes the task of 
identifying a user extremely difficult. But there is no 
need to authenticate a user in the case of IIS. When IIS 
receives a request for a web page or other resource that 
has permission for anonymous access, IIS treats the 
IUSR_machinename account as the user's account, to access 
the resources. If the resource requested by the user is an 
ASP page that uses a COM or COM+ component, that component 
is executed using the IWAM_machinename account. 
............................................................
81)What is default impersonation in asp.net?
Ans: 
When using impersonation, ASP.NET applications can optionally execute with the identity of the client on whose behalf they are operating. The usual reason for doing this is to avoid dealing with authentication and authorization issues in the ASP.NET application code. Instead, you rely on IIS to authenticate the user and either pass an authenticated token to the ASP.NET application or, if unable to authenticate the user, pass an unauthenticated token. In either case, the ASP.NET application impersonates whichever token is received if Impersonation is enabled. The ASP.NET application, now impersonating the client, then relies on the settings in the NTFS directories and files to allow it to gain access, or not. Be sure to format the server file space as NTFS, so that access permissions can be set.
For ASP compatibility, impersonation is disabled by default. If impersonation is enabled for a given application, ASP.NET always impersonates the access token that IIS provides to ISAPI extensions. That token can be either an authenticated user token, or the token for the anonymous user ( such as IUSR_MACHINENAME ). The impersonation occurs regardless of the type of authentication being used in the application and whether the user is authenticated, in which case, it is the anonymous user token.
Only application code is impersonated; compilation and configuration are read as the process token. If an application is on a UNC share, ASP.NET will always impersonate the token provided to IIS to access that share unless a configured account is used. If an explicit configured account is provided, ASP.NET will use that account in preference to the IIS UNC token. Applications that do want per-request impersonation can simply be configured to impersonate the user making the request.
Impersonation is disabled at the computer level by default and, unless overridden, all the application domains inherit this setting. You can enable impersonation by putting a configuration file in the application root directory. For more information about the ASP.NET configuration system, see ASP.NET Configuration.
As is the case with other configuration directives, this directive applies hierarchically. It is respected by nested applications in the hierarchy, unless explicitly overridden. The default value for this setting is as follows:
<impersonation enable = "false" /> A minimal configuration file to enable impersonation for an application might look similar to the following example:
<identity impersonate = "true" name = "username" password = "password" /> There is also name support for running an application as a configurable identity. For example:
<identity impersonate = "true" name = "Redmond\Dev" password = "bar" /> This enables the entire application to run as Redmond\Dev, regardless of the identity of the request, so long as the password is correct. This type of impersonation can be delegated to another computer.
....................................................................................................................................................
82)What is interface?

Ans:
An interface looks like a class, but has no implementation. It contains 
definitions of events, indexers, methods and properties. An interface 
inherited by classes An interface inheritance defined with keyword 
"interface". In C# Interface Inheritance also known as multiple 
inheritances.
.................................................................................
83)Usage of interface?
Ans:

Safe Changes to Code

Interfaces eliminate a significant problem of class inheritance: the likelihood of breaking code when you make post-implementation changes to your design. Even though class inheritance allows your classes to inherit implementation from a base class, it also forces you to make most of your design decisions when the class is first published. If your original assumptions turn out to be incorrect, you cannot always change your code safely in later versions.
For instance, suppose you define a method of a base class that expects an Integer argument, and then later determine that the argument should be of the Long data type. You cannot safely change the original class, because applications designed for classes derived from the original may not compile correctly. This problem can be magnified because a single base class can affect hundreds of subclasses.
One solution is to define a new method that overloads the original and that takes an argument of type Long. However, this might not be satisfactory because a derived class may need to override the method that takes the integer, and may not function properly if the method that takes a Long is not overridden also. Interfaces solve this problem by allowing you to publish an updated interface that accepts the new data type.

Flexibility in Implementation

There are several other reasons why you might want to use interfaces instead of class inheritance:
  • Interfaces are better suited to situations in which your applications require many possibly unrelated object types to provide certain functionality.
  • Interfaces are more flexible than base classes because you can define a single implementation that can implement multiple interfaces.
  • Interfaces are better in situations in which you do not need to inherit implementation from a base class.
  • Interfaces are useful in cases where you cannot use class inheritance. For example, structures cannot inherit from classes, but they can implement interfaces.
 
................................................................................. 
84)What is abstract?
Ans: Abstract class is a class that can not be instantiated, it exists 
extensively for inheritance and it must be inherited. There are 
scenarios in which it is useful to define classes that is not intended 
to instantiate; because such classes normally are used as base-classes 
in inheritance hierarchies, we call such classes abstract classes.



Abstract classes cannot be used to instantiate objects; because 
abstract classes are incomplete, it may contain only definition of the 
properties or methods and derived classes that inherit this implements 
it's properties or methods.



Static, Value Types & interface doesn't support abstract 
modifiers. Static members cannot be abstract. Classes with abstract 
member must also be abstract
.........................................................................
85)Interface methods are public and protected? Is it right?
Ans: If I use an interface internally for my application, to aid future

enhancement and maintainability.

All the methods will still be public.



I have a validation method which ordinarilly would be private.

It simply does nothing if validation succeeds or throws exceptions

otherwise.

Not a typical public method.



From a javadocs point of view this method will be right out there with the

rest of the public interface



I notice Sun has statements like this for some undesirably exposed methods:



"This method is public as an implementation side effect. do not call or

override."
...............................................................................
86)What is protected?
Ans: 
The Protected keyword confers protected access on one or more declared programming elements. Protected elements are accessible only from within their own class or from a derived class. Protected access is not a superset of friend access.
The Protected keyword can be used in conjunction with the Friend keyword in the same declaration. This combination confers both friend and protected access on the declared elements, so they are accessible from the same assembly, from their own class, and from any derived classes.
...........................................................................................................
87)What is polymorphism?
Ans:
  • Polymorphism is one of the primary characteristics (concept) of object-oriented programming.
  • Poly means many and morph means form. Thus, polymorphism refers to being able to use many forms of a type without regard to the details.
  • Polymorphism is the characteristic of being able to assign a different meaning specifically, to allow an entity such as a variable, a function, or an object to have more than one form.
  • Polymorphism is the ability to process objects differently depending on their data types.
  • Polymorphism is the ability to redefine methods for derived classes.
  • visit("http://www.dotnetfunda.com/articles/article505-what-is-polymorphism-.aspx")
.....................................................................................................................
88)Diff between overloading and overriding?
Ans:Overloading:
====================
Overloading means having more than one method with the same name, but a different list of arguments in the same class or in a combination of base and derived classes.

Overriding:
====================
Overriding means have a method with the same name and the same signature in the same class and derived classes.

.............................................................................................
89)How to restrict my class to inherited?
Ans:Using Static key word Avoidind Inhertence 
...........................................................................
90)How to restrict my class to create object?
Ans:Declare Class is a private avoid Object Creation
.......................................................................................................
91)What is delegate?
Ans:i) Delegate is a function pointer.
ii) It allows the programmer to encapsulate a reference to a method inside a delegate object.
iii)Delegates are type-safe and secure.
iv) Delegates are created at run time.

............................................................................................
92)What is thread?
Ans:
A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently of everything else that might be happening. A thread is like a classic program that starts at point A and executes until it reaches point B. It does not have an event loop. A thread runs independently of anything else happening in the computer. Without threads an entire program can be held up by one CPU intensive task or one infinite loop, intentional or otherwise. With threads the other tasks that don't get stuck in the loop can continue processing without waiting for the stuck task to finish.
It turns out that implementing threading is harder than implementing multitasking in an operating system. The reason it's relatively easy to implement multitasking is that individual programs are isolated from each other. Individual threads, however, are not. To return to the printing example, suppose that while the printing is happening in one thread, the user deletes a large chunk of text in another thread. What's printed? The document as it was before the deletion? The document as it was after the deletion? The document with some but not all of the deleted text? Or does the whole system go down in flames? Most often in a non-threaded or poorly threaded system, it's the latter.
Threaded environments like Java allow a thread to put locks on shared resources so that while one thread is using data no other thread can touch that data. This is done with synchronization. Synchronization should be used sparingly since the purpose of threading is defeated if the entire system gets stopped waiting for a lock to be released. The proper choice of objects and methods to synchronize is one of the more difficult things to learn about threaded programming.
......................................................................................................................
93) What are the Ado.net objects?
Ans:
This chapter defines basic data objects as runtime data-access types that have ADODB counterparts. ADO.NET 2.0 provides the following basic data objects for data retrieval, updates, or both:
  • Connection objects define the data provider, database manager instance, database, security credentials, and other connection-related properties. The VB 2005 code to create a .NET Connection is quite similar to the VB6 code to create an ADODB.Connection object. You also can create a new, persistent (design-time) Connection object by right-clicking Server Explorer's Data Connections node and choosing Add Connection to open the Connection Properties dialog. Alternatively, choose Tools➪Connect to Database to open the dialog.
  • Command objects execute SQL batch statements or stored procedures over an open Connection. Command objects can return one or more resultsets, subsets of a resultset, a single row, a single scalar value, an XmlDataReader object, or the RowsAffected value for table updates. Unlike opening ADODB.Recordset objects from an ADODB.Connection, the ADO.NET Command object isn't optional. Command objects support an optional collection of Parameter objects to execute parameterized queries or stored procedures. The relationship of ADODB and ADO.NET parameters to commands is identical.
  • DataReader objects retrieve one or more forward-only, read-only resultsets by executing SQL batch statements or stored procedures. VB .NET code for creating and executing a DataReader from a Command object on a Connection object is similar to that for creating the default, cursorless ADODB Recordset object from an ADODB.Command object. Unlike the default forward-only ADODB.Recordset, you can't save a DataReader's resultset to a local file and reopen it with a client-side cursor by Save and Open methods.
  • XmlReader objects consume streams that contain well-formed XML documents, such as those produced by SQL Server FOR XML AUTO queries or stored procedures, or native xml columns of SQL Server 2005. XmlReaders are the equivalent of a read-only, forward-only cursor over the XML document. An XmlReader object corresponds to the ADODB.Stream object returned by the SQLXML 3.0 and later SQLXMLOLEDB provider.
Refer :http://searchsqlserver.techtarget.com/feature/Basic-ADONET-data-objects
Refer:http://www.exforsys.com/tutorials/vb.net-2005/access-and-manipulate-data-the-ado-.net-object-model.html


Any new Quationa Avilable Please Post Quations