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.

9:55 AM

mechine.config Vs Web.config

Posted by pradeep T

When you modify the settings in the Web.Config file, you do not need to restart the Web service for the modifications to take effect.. By default, the Web.Config file applies to all the pages in the current directory and its subdirectories.


You can use the tag to lock configuration settings in the Web.Config file so that they cannot be overridden by a Web.Config file located below it. You can use the allowOverride attribute to lock configuration settings. This attribute is especially valuable if you are hosting untrusted applications on your server.

There are number of important settings that can be stored in the configuration file. Here are some of the most frequently used configurations, stored conveniently inside Web.config file..

1. Database connections.

2. Session States

3. Error Handling (CustomError Page Settings.)

4. Security (Authentication modes)

The Machine.Config file, which specifies the settings that are global to a particular machine. This file is located at the following path:



\WINNT\Microsoft.NET\Framework\[Framework Version]\CONFIG\machine.config



As web.config file is used to configure one asp .net web application, same way Machine.config file is used to configure the application according to a particular machine. That is, configuration done in machine.config file is affected on any application that runs on a particular machine. Usually, this file is not altered and only web.config is used which configuring applications.

9:53 AM

Page Life Cycle

Posted by pradeep T

An important article on the different methods and order they are executed during the load of an .aspx web page. ASP.NET.
In this article, we are going to discuss the different methods and order they are executed during the load of an .aspx web page.

When a visitor first requests an .aspx page on your server, the server sends it to the HTTP Pipeline. The HTTP Pipeline handles all processes involved in converting all of the application code into HTML to be interpreted by the browser. The first class initiated is called HttpRuntime. This class finds a free HttpApplication object to start processing the request. The HttpApplication object then runs the appropriate handler assigned in the web.config and machine.config files for the requested extension.

The extension .aspx can be handled by the HandlerClass or HandlerFactory class. The HttpApplication objects starts the IHttpHandler interface which begins processing the application code by calling the processRequest() method.

Need help with Windows Dedicated Hosting? Try Server Intellect. I'm a happy customer!

The processRequest() method then calls the FrameworkInitialize() method which begins building the control trees for the requested page. Now the processRequest() method cycles through the page's life cycle in the order listed below.

Methods Description
Page_Init Page Initialization
LoadViewState View State Loading
LoadPostData Postback Data Processing
Page_Load Page Loading
RaisePostDataChangedEvent PostBack Change Notification
RaisePostBackEvent PostBack Event Handling
Page_PreRender Page Pre Rendering Phase
SaveViewState View State Saving
Page_Render Page Rendering
Page_Unload Page Unloading
The first processed method is Page_Init(). Once the control tree has been created, the controls declared in the .aspx file are initialized. The controls can modify some of the settings set in this method to be used later in the page life cycle. Obviously no other information is available to be modified at this time.

The next processed method is LoadViewState(). The Viewstate contains stored information that is set by the page and controls of the page. This is carried to and from every aspx page request per visitor.

I just signed up at Server Intellect and couldn't be more pleased with my Windows Server! Check it out and see for yourself.

The next processed method is LoadPostData(). These are values associated with the HTML form elements the visitor has typed, changed or selected. Now the control has access to this information which can update their stored information pulled from the Viewstate.

The next processed method is Page_Load(). This method should look familiar and is usually the most common used method on the server side application code for an .aspx file. All code inside of this method is executed once at the beginning of the page.

The next processed method is RaisePostDataChangedEvent(). When a visitor completes a form and presses the submit button, an event is triggered. This change in state signals the page to do something.

The next processed method is RaisePostBackEvent(). This method allows the page to know what event has been triggered and which method to call. If the visitor clicks Button1, then Button1_Click is usually called to perform its function.

Server Intellect offers Windows Hosting Dedicated Servers at affordable prices. I'm very pleased!

The next processed method is Page_PreRender(). This method is the last chance for the Viewstate to be changed based on the PostBackEvent before the page is rendered.

The next processed method is SaveViewState(). This method saves the updated Viewstate to be processed on the next page. The final Viewstate is encoded to the _viewstate hidden field on the page during the page render.

The next processed method is Page_Render(). This method renders all of the application code to be outputted on the page. This action is done with the HtmlWriter object. Each control uses the render method and caches the HTML prior to outputting.

The last processed method is Page_Unload(). During this method, data can be released to free up resources on the server for other processes. Once this method is completed, the HTML is sent to the browser for client side processing.

Now you should have a little bit better understanding of the order of methods executed in the request of an .aspx file.

courtesy :http://www.dotnettutorials.com/tutorials/performance/page-life-cycle-asp.aspx

4:37 PM

Origin of Logs

Posted by pradeep T

Links
http://logbase2.blogspot.com/2007/12/log-base-2.html


History of Logarithms
Logarithms were invented independently by John Napier, a Scotsman, and by Joost Burgi, a Swiss. Napier's logarithms were published in 1614; Burgi's logarithms were published in 1620. The objective of both men was to simplify mathematical calculations. This approach originally arose out of a desire to simplify multiplication and division to the level of addition and subtraction. Of course, in this era of the cheap hand calculator, this is not necessary anymore but it still serves as a useful way to introduce logarithms. Napier's approach was algebraic and Burgi's approach was geometric. The invention of the common system of logarithms is due to the combined effort of Napier and Henry Biggs in 1624. Natural logarithms first arose as more or less accidental variations of Napier's original logarithms. Their real significance was not recognized until later. The earliest natural logarithms occur in 1618.
It can’t be said too often: a logarithm is nothing more than an exponent. The basic concept of logarithms can be expressed as a shortcut........ Multiplication is a shortcut for Addition: 3 x 5 means 5 + 5 + 5
Exponents are a shortcut for Multiplication: 4^3 means 4 x 4 x 4
Logarithms are a shortcut for Exponents: 10^2 = 100.
The present definition of the logarithm is the exponent or power to which a stated
number, called the base, is raised to yield a specific number.
The logarithm of 100 to the base 10 is 2. This is written: log10 (100) = 2.
Before pocket calculators — only three decades ago, but in “student years” that’s the age of dinosaurs — the answer was simple. You needed logs to compute most powers and roots with fair accuracy; even multiplying and dividing most numbers were easier with logs. Every decent algebra books had pages and pages of log tables at the back.
The invention of logs in the early 1600s fueled the scientific revolution. Back then scientists, astronomers especially, used to spend huge amounts of time crunching numbers on paper. By cutting the time they spent doing arithmetic, logarithms effectively gave them a longer productive life. The slide rule, once almost a cartoon trademark of a scientist, was nothing more than a device built for doing various computations quickly, using logarithms. See Eli Maor’s e: The Story of a Number for more on this.
Today, logs are no longer used in routine number crunching. But there are still good reasons for studying them. Why do we use logarithms, anyway?
• To find the number of payments on a loan or the time to reach an investment goal
• To model many natural processes, particularly in living systems. We perceive loudness
of sound as the logarithm of the actual sound intensity, and dB (decibels) are a logarithmic scale. We also perceive brightness of light as the logarithm of the actual light energy, and star magnitudes are measured on a logarithmic scale.
• To measure the pH or acidity of a chemical solution. The pH is the negative logarithm of the concentration of free hydrogen ions.
• To measure earthquake intensity on the Richter scale.
• To analyze exponential processes. Because the log function is the inverse of the
exponential function, we often analyze an exponential curve by means of logarithms. Plotting a set of measured points on “log-log” or “semi-log” paper can reveal such relationships easily. Applications include cooling of a dead body, growth of bacteria, and decay of a radioactive isotopes. The spread of an epidemic in a population often follows a modified logarithmic curve called a “logistic”.
• To solve some forms of area problems in calculus.
(The area under the curve 1/x, between x=1 and x=A, equals ln A.)

1:54 PM

Algos Problems

Posted by pradeep T

Prime number computation
topological sorting - library of machine parts- each part should be placed in the order of useage
dynamic programming - DNA Matching - (A,B,C,D,F) .. (B,C,D) close match
convex hull or convex envelope
discrete Fourier transforms

1:16 PM

Links for DS

Posted by pradeep T

http://cgm.cs.mcgill.ca/~godfried/teaching/algorithms-web.html
http://sbge.tripod.com/DSIndex.html
http://www.cs.berkeley.edu/~jrs/61b/lec/07
http://www.cs.auckland.ac.nz/~jmor159/PLDS210/ds_ToC.html

Finite automata
Computation Theory
Complexity Theory

1:12 PM

Smart pointers

Posted by pradeep T

To be smarter than regular pointers, smart pointers need to do things that regular pointers don't. What could these things be? Probably the most common bugs in C++ (and C) are related to pointers and memory management: dangling pointers, memory leaks, allocation failures and other joys. Having a smart pointer take care of these things can save a lot of aspirin...

The simplest example of a smart pointer is auto_ptr, which is included in the standard C++ library. You can find it in the header , or take a look at Scott Meyers' auto_ptr implementation. Here is part of auto_ptr's implementation, to illustrate what it does:

template class auto_ptr
{
T* ptr;
public:
explicit auto_ptr(T* p = 0) : ptr(p) {}
~auto_ptr() {delete ptr;}
T& operator*() {return *ptr;}
T* operator->() {return ptr;}
// ...
};
As you can see, auto_ptr is a simple wrapper around a regular pointer. It forwards all meaningful operations to this pointer (dereferencing and indirection). Its smartness in the destructor: the destructor takes care of deleting the pointer.