Place Holder

This control can hold any control generated at run time. Example:

<%Page Language=”C#” AutoEventWireup=”true” CodeFile=“PlaceHolder.aspx.cs” Inherits=”PlaceHolder” %>

<script runat=”server”>

runat=”server”

The form tag includes a name and the code runat=”server” This little code line means that everything will be taken care of by the server.

@ Page Language=”C#”

This first segment lets the page know that the language in use is C# and not VB or some other language. It’s pretty self-explanatory.

AutoEventWireup=”true”

The AutoEventWireup Boolean indicates whether the ASP.NET pages are automatically connected to event-handling functions. With C#, the default is set to true, so the pages are connected to event-handling functions.

CodeFile=”Default.aspx.cs”

The final section indicates the name of the C# file and what it inherits.  Since the name of the ASP.NET design file is Default.aspx the CodeFile is Default.aspx.cs.

Inherits=”_Default” 

The Inherits attribute refers to the name of the class that the code inherits.

Read More

Web Form Life Cycle

The life cycle begins with a request for the page, which causes the server to load it. When the request is complete, the page is unloaded. The life cycle of a page is marked by the following events:

Initialize: Initialize is the first phase in the life cycle for any page or control. It is here that any settings needed for the duration of the incoming request are initialized.

Load ViewState: The ViewState property of the control is populated. The ViewState information comes from a hidden variable on the control, used to persist the state across round trips to the server. The input string from this hidden variable is parsed by the page framework, and the ViewState property is set. This can be modified via the LoadViewState( ) method: This allows ASP.NET to manage the state of your control across page loads so that each control is not reset to its default state each time the page is posted.

Process Post back Data: During this phase, the data sent to the server in the posting is processed. If any of this data results in a requirement to update the ViewState, that update is performed via the LoadPostData ( ) method.

Load: CreateChildControls ( ) is called, if necessary, to create and initialize server controls in the control tree. State is restored, and the form controls show client-side data. You can modify the load phase by handling the Load event with the OnLoad method.

Send Postback Change Modifications: If there are any state changes between the current state and the previous state, change events are raised via the  RaisePostDataChangedEvent( )  method.

Handle Postback Events: The client-side event that caused the postback is handled.

 PreRender: This is the phase just before the output is rendered to the browser. It is essentially your last chance to modify the output prior to rendering using the OnPreRender ( ) method.

Save State: Near the beginning of the life cycle, the persisted view state was loaded from the hidden variable. Now it is saved back to the hidden variable, persisting as a string object that will complete the round trip to the client. You can override this using the SaveViewState () method.

Render: This is where the output to be sent back to the client browser is generated. You can override it using the Render method. CreateChildControls ( ) is called, if necessary, to create and initialize server controls in the control tree.

Dispose: This is the last phase of the life cycle. It gives you an opportunity to do any final cleanup and release references to any expensive resources, such as database connections. You can modify it using the Dispose ( ) method.

Read More

Server

The node (computer) on network which provides services to the clients is known as server.

Web server examples

Java’s->Tomcat Apache, Wamp Server

Netscape’s ->Netscape

ASP-> IIS (Internet Information Services) (Inetpub (internet publishing) folder-wwwroot (is the default folder for IIS where stay all the ASP files to execute))

PHP-> Wamp and Xamp server

Read More

Types of scripting in ASP.Net

There are two types of scripting. Server side scripting and client (browser) side scripting.

Client side scripting is used to create and decorate pages which will display on browser.  It is browser dependent.

Example: Java Script and VB Scripting.

Server side scripting is used for operations (sending, receiving, calculating and storing data in database). All these operation are performed on server by asp and jsp and php.

Example:  ASP and JSP, PHP.

 Difference Between Client Side Scripting and Server Side Scripting

S.No.Client Side ScriptingServer Side Scripting
1.Script code is downloaded and executed at client side i.e pages will run on browser.The script is executed at the server End and the result is send to the client End.

2.Response to interaction is more immediate once the program code has been downloaded.

Complex process is more efficient as the program and associated resources are not downloaded to the browser.

3.Client are source as they do not have access to files and database. It is only for designing not for operations.

Have access to files and databases but have security considerations when sending sensitive information.

4.This scripting is browser dependent and behaves differently for every browser.

Does not depend on browser.

5.Affected by the processing speed of user’s computer.

Affected by the processing speed of the host server.
Read More

Connection String

The connection string defines which database server you are using, where It resides, your user name and password and optionally the database name.

//for SQL server

string  constr=”server=.; database=dbemployee; uid=sa; pwd=;” ;

//for SQL Express

string  constr=”server=.sqlexpress; database=dbemployee; uid=sa; pwd=;” ;

.sqlexpress – server name on the computer

Dbemployee – name of database with which we are dealing

sa – System administrator, user responsible for login in database.

Pwd – password which is blank if not given to the database otherwise we have to mentioned if given at the time of database creation.

SqlConnection cn = new SqlConnection(@”Data Source=.SQLEXPRESS;AttachDbFilename=”+ Application .StartupPath +“\dbdemo.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True”);

Read More

Specific Classes of ADO.Net

ADO.Net also contains some database specific classes. This means that different database system providers may provides classes or drivers optimized for their particular database system. Microsoft has also provided the general classes which can connect your application to any OLE supported database server. The name of these classes starts with OleDb and these are contained in the System.Data.OleDb namespace. In fact we can you use OleDb classes to connect to SQL server or Oracle database, using the database specific classes generally provides optimized performance.

ClassDescription
SqlConnection, OleDbConnectionRepresents a connection to the database system.
SqlCommand, OleDbCommandRepresents SQL query
SqlDataAdapter, OleDbDataAdapterA class that connects to the database system fetches the records and fills the dataset.

SqlDataReader, OleDbDataReaderA stream that reads data from the database in a connected design.

SqlParameter, OleDbParameterRepresents a parameter to a stored procedure.
Read More

Components of ADO.Net

All generic classes for data access are contained in the System.Data namespace.

 ClassDescription
DataSetThe DataSet is a local buffer of tables or a collection of disconnected       records sets.
DataTable

 A DataTable is used to contain data in tabular form using rows and   columns

DataRow Represents a single record or row in a DataTable.

DataColumn

 Represents a column or field of  a DataTable

DataRelation

 Represents the relationship between different tables in a data set.

Constraint Represents the constraints or limitations that apply to a particular field or column.
Read More

About Javascript

25 Aug Admin

o      JavaScript is an interpreted, client-side, event-based, objectoriented scripting language that you can use to add dynamic interactivity to your web pages.

o       JavaScript scripts are written in plain text, like HTML, XML, Java, PHP and just about any other modern computer code. In     this code, we will use Windows NotePad to create and edit our JavaScript code, but there are a large number of alternatives   available. NotePad is chosen to demonstrate JavaScript’s immediacy and simplicity.

o      You can use JavaScript to achieve any of the following:

    §  Create special effects with images that give the impression that a button is either highlighted or depressed whenever the mouse    pointer is hovered o ver it.

§  Validate information that users enter into your web forms

§  Open pages in new windows, and customise the appearance of those new windows.

§  Detect the capabilities of the user’s browser and alter your page’s content appropriately.

§  Create custom pages “on the fly” without the need for a server-side language like PHP.

§  And much more…

o      JavaScript is not Java, though if you come from a Java background, you will notice that both languages look similar when written. Java is a full featured and comprehensive programming language similar to C or C++, and although JavaScript can interact with Java web applications, the two should not be confused.

o      Different web browsers will run your JavaScript in different, sometimes incompatible ways. In order to work around this, it is often necessary to use JavaScript itself to detect the capabilities of the browser in which it finds itself, and alter its operation depending on the result.

o      To revisit the original definition in this chapter, note the following points:

§  Interpreted refers to the fact that JavaScript code is executed (acted on) as it is loaded into the browser. This is a change of pace from compiled languages like Java, which check your program thoroughly before running a single line of code, and can have many implications that can catch you out if you are from a non-interpreted programming background.

§  Client-side has been defined already in the previous chapter.

§  Event-based refers to JavaScript’s ability to run certain bits of code only when a specified event occurs. An event could be the page being loaded, a form being submitted, a link being clicked, or an image being pointed at by a mouse pointer.

§  Object-oriented signals that JavaScript’s power to exert control over an HTML page is based on manipulating objects within that page. If you are familiar with object-oriented programming, you will be aware of some of the power that this can bring to the coding environment.

One final note: While JavaScript is a programming language, HTML (the language of the World Wide Web) is not. HTML is a Markup Language, which means that it can be used to mark areas of a document as having special characteristics like headers, paragraphs, images, forms and so on, but it cannot perform any logical processing on its own. So while JavaScript is often written alongside HTML, the rules of one do not necessarily have any bearing on the other. 

Read More

Data set

The application stays connected to the DB system even when it is not using DB services. This commonly wastes valuable and expensive database resources, as most of the time applications only query and view the persistent data. ADO.Net solves this problem by managing a local buffer of persistent data called data set. 
Our application automatically connects to the database server when it needs to run a query and then disconnects immediately after getting the result back and storing it in the dataset. This design of ADO.Net is called disconnected data architecture and is very much similar to the connectionless services of HTTP on the internet. ADO.Net also provides connection oriented traditional data access services.
An important aspect of disconnected architecture is that it maintains a local repository of data in the dataset object. The dataset object stores the tables, their relationship and their different constraints. The user can perform operations like update, insert and delete on this dataset locally, and the changes made to the dataset are applied to the actual database as a batch when needed. This greatly reduces network traffic and results in better performance.
 

Read More