10:00 AM

FAQ .NET

Posted by pradeep T

How to prevent a Button from validating its form?
Set the CauseValidation property of the button control to false.


How can you change a Master Page dynamically at runtime?
To change a master page, set the MasterPageFile property of the @Page directive to point to the .master page during the PreInit page event.

What is a proxy of the server object in ASP.Net Remoting?
It is a fake copy of the server object that resides on the client side and behaves as if it was the server. It handles the communication between real server object and the client object. This process is also known as marshaling.

What is DataReader Object in ADO.Net?
It provides a forward-only, read-only, connected recordset.

It is most efficient to use when data need not to be updated, and requires forward only traverse. In other words, it is the fastest method to read data.

Example:

Filling dropdownlistbox.
Comparing username and password in database.
SqlDataReader rdr = cmd.ExecuteReader();

//Reading data

while (rdr.Read())
{

//Display data

string contact = (string)rdr["ContactName"];
string company = (string)rdr["CompanyName"];
string city = (string)rdr["City"];

}

What are the components of .NET DataProvider?

Posted by: Abhisek
The .NET DataProvider is a set of components that includes the Connection, Command, DataReader and DataAdapter objects. It is used for connecting to a database , executing commands and retrieving results. Using the .NET data provider we can either access database directly or use the disconnected approach. For the disconnected approach we use DataSet class.

Connection Object:- It is used to connect to the data source. Data source can be any database file. The connection object contains information like the provider name, server name, datasource name, user name and password.

Command Object:- It is used for connect the connection object to a DataReader or DataAdapter object. The command object allow us to execute SQL statement or a stored procedure in a data source.

DataReader Object:- It is used to read the data in a fast and efficient manner from the database. It is generally used to extract one or a few records or specific field values or to execute simple SQL statement.

DataAdapter Object:- It is used to fill data from the database into the DataSet object. it is use din the disconnected approach

Give Expansions of ODBC,OLE,OLE DB,ADO?

Posted by: Vpramodg
1.ODBC-Open Database Connectivity.
2.OLE-Object Linking and Embedding.
3.OLE DB-Object Linking and Embedding for Database.
4.ADO-ActiveX Data Object.

Components of data providers in ADO.NET?

Posted by: Tripati_tutu
Connection Object: The Connection object represents the connection to the database. The Connection object has ConnectionString which contains all the information required to connect to the database.

Command Object: The command object is used to execute stored procedures and command on the database. It contains methods such as ExecuteNonQuery, ExecuteScalar and ExecuteReader.

ExecuteNonQuery: It executes a command that doesn’t return any record, such as INSERT, UPDATE and DELETE.

ExecuteScalar: It executes and returns a single value from a database.

ExecuteReader: It returns a result set by the DataReader object.

DataReader Object: It provides a connected, forward-only and read-only recordset from a database. The Command.ExecuteReader method creates and returns a DataReader object. Since it is connected to the database through out its lifetime, it requires the use of connection object.

DataAdapter Object: This object acts like a communication bridge between the database and a dataset. It fills the dataset with data from the database. The dataset stores the data in the memory and it allows changes. The DataAdapter update method can transmit the changes to the database.

In connected data access you can connect through the DataReader objects of data provider. This object requires exclusive use of the connection object. It can provide fast and forward-only data access. It doesn't allow editing.

Disconnected data access is achieved through the DataAdapter object. This object establishes connection, executes the command, load data in the DataSet. The Dataset works independent of database. It contains data in the memory and can edit the data. The changes in the data can be transmitted to the database using Update method of DataAdapter object.

What are the types of authentication in ASP.Net?
ASP.Net provides infrastructure for authentication and authorization that will meet most of your needs for securing an .Net application. Four schemes are available in ASP.Net:
1. Forms-based authentication
2. Windows-based authentication
3. Microsoft Passport authentication
4. None - authentication disabled

Authentication is the process of identifying and verifying who the client accessing the server is.
For example, if you use

Windows authentication and are browsing an ASP.NET page from server -- ASP.NET/IIS would automatically use NTLM to authenticate you as SYNCFUSION\user1 (for example).
Forms based authentication, then you would use an html based forms page to enter username/password -- which would then check a database and authenticate you against the username/password in the database.

Authorization is the process of determining whether an authenticated user has access to run a particular page within an ASP.NET web application. Specifically, as an application author decide to grant or deny the authenticated user "SYNCFUSION\user1" access to the admin.aspx page. This could be done either by explictly granting/denying rights based on the username -- or use role based mappings to map authenticated users into roles (for example: an administrator might map "SYNCFUSION\user1" into the "Power Users" role) and then grant/deny access based on role names (allowing a degree of abstraction to separate out your authorization pol


ASP.Net Interview Questions and Answers


What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
ViewState is the mechanism used by the ASP.Net to keep track of server control state values that do not otherwise post back as part of the HTTP form. ViewState Maintains the UI State of a web page.
ViewState is base64-encoded. It is not encrypted but it can be encrypted by setting EnableViewStatMAC="true" & setting the machineKey validation type to 3DES. If you want to not to maintain the ViewState, include the directive <%@ Page EnableViewState="false" %> at the top of an .aspx page or add the attribute EnableViewState="false" to any control.

What is Cross Page Posting? How is it done?
By default, ASP.Net submits a form to the same page. In cross-page posting, the form is submitted to a different page. This is done by setting the PostBackUrl property of the button(that causes postback) to the desired page. In the code-behind of the page to which the form has been posted, use the FindControl method of the PreviousPage property to reference the data of the control in the first page.


What is a satellite assembly?
When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.


How to set a cookie?
HttpCookie myCookie = new HttpCookie("myWebSiteName");
myCookie.Value = "http://www.faqpanel.com/";
myCookie.Expires = DateTime.Now.AddMonths(6);
Response.Cookies.Add(myWebSiteName);

What is connection pooling in ASP.Net?
Connection pooling increases the performance of Web applications by reusing active database connections instead of creating a new connection with every request. Connection pool manager maintains a pool of open database connections. When a new connection requests come in, the pool manager checks if the pool contains any unused connections and returns one if available. If all connections currently in the pool are busy and the maximum pool size has not been reached, the new connection is created and added to the pool. When the pool reaches its maximum size all new connection requests are being queued up until a connection in the pool becomes available or the connection attempt times out.

How can you change a Master Page dynamically at runtime?
To change a master page, set the MasterPageFile property of the @Page directive to point to the .master page during the PreInit page event.


SESSION
http://www.codeproject.com/Articles/32545/Exploring-Session-in-ASP-Net

What does an assembly contain?
A ASP.Net assembly may contain the following elements:
1. Assembly Manifest - Metadata that describes the assembly and its contents
2. Source Code - Compiled into Microsoft intermediate language
3. Type Metadata - Defines all types, their properties and methods, and most importantly, public types exported from this assembly
4. Resources - Icons, images, text strings and other resources

What is the smallest unit of execution in ASP.Net?
An Assembly.
What is a formatter in ASP.Net Remoting?
A formatter is an object that is responsible for encoding and serializing data into messages on one end, and deserializing and decoding messages into data on the other end.

DELEGATES:

* Event is Arraylist of delegates .
* Delegate ( as its English meaning ) : Secretary or someone who connect two persons throuh him .
* Delegate can fire only one method
But Event fire more than one delegate , each call one method

* Example : in Windows App. or ASP.NET App.
Button : is a class that has internally an event called ( eg. click ) and there is
a method you want to do if this button clicked so make an instance of the delegate
which button.click deal with ( System.EventHandler ) and make this delegate
execute the method eg. Button1_Click

Code :
in initializer of The Form Class :
Button1.Click += new System.EventHandler(this.button1_Click) ;
And make amethod :
private void button1_Click(object sender, System.EventArgs e)
{
// write your own code
}


n brief, you can think of an event as being a bit like a property - but instead of having get/set operations, it has add/remove. The value being added/removed is always a delegate reference.

Delegates themselves support operations of:

Combine (chain multiple delegate instances together)
Remove (split them up again)
Invoke (synchronous or asynchronous)
Various things to do with finding out the target, invocation list etc
Note that delegates themselves are immutable, so combine/remove operations return a new delegate instance rather than modifying the existing ones.

Basically, a delegate is just a wrapper around what would be a function pointer in C (or a list of function pointers).

An event is an even higher level abstraction that wraps the concept of a delegate together with methods to subscribe and unsubscribe a method to such delegates.

An event is a “property” that exposes an add and remove method (invoked via += and -= in code) to add/remove subscribers to a delegate list.

0 comments: