Saturday 10 December 2011

Imp qus in asp .net2


What are the different namespaces used in the project to connect the database? What data providers available in .net to connect to database ? 

•    System.Data.OleDb – classes that make up the .NET Framework Data Provider for OLE DB-compatible data sources. These classes allow you to connect to an OLE DB data source, execute commands against the source, and read the results.
•    System.Data.SqlClient – classes that make up the .NET Framework Data Provider for SQL Server, which allows you to connect to SQL Server 7.0, execute commands, and read results. The System.Data.SqlClient namespace is similar to the System.Data.OleDb namespace, but is optimized for access to SQL Server 7.0 and later.
•    System.Data.Odbc - classes that make up the .NET Framework Data Provider for ODBC. These classes allow you to access ODBC data source in the managed space.
•    System.Data.OracleClient - classes that make up the .NET Framework Data Provider for Oracle. These classes allow you to access an Oracle data source in the managed space.

Difference between OLEDB Provider and SqlClient ? 

SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It’s faster than the Oracle provider, and faster than accessing database via the OleDb layer. It’s faster because it accesses the native library (which automatically gives you better performance), and it was written with lots of help from the SQL Server team.

What are relation objects in dataset and how & where to use them ? 

In a DataSet that contains multiple DataTable objects, you can use DataRelation objects to relate one table to another, to navigate through the tables, and to return child or parent rows from a related table.  Adding a DataRelation to a DataSet adds, by default, a UniqueConstraint to the parent table and a ForeignKeyConstraint to the child table.
The following code example creates a DataRelation using two DataTable objects in a DataSet. Each DataTable contains a column named CustID, which serves as a link between the two DataTable objects. The example adds a single DataRelation to the Relations collection of the DataSet. The first argument in the example specifies the name of the DataRelation being created. The second argument sets the parent DataColumn and the third argument sets the child DataColumn.
custDS.Relations.Add(”CustOrders”,
custDS.Tables[”Customers”].Columns[”CustID”],
custDS.Tables[”Orders”].Columns[”CustID”]);

OR
private void CreateRelation()
{
// Get the DataColumn objects from two DataTable objects in a DataSet.
DataColumn parentCol;
DataColumn childCol;
// Code to get the DataSet not shown here.
parentCol = DataSet1.Tables[”Customers”].Columns[”CustID”];
childCol = DataSet1.Tables[”Orders”].Columns[”CustID”];
// Create DataRelation.
DataRelation relCustOrder;
relCustOrder = new DataRelation(”CustomersOrders”, parentCol, childCol);
// Add the relation to the DataSet.
DataSet1.Relations.Add(relCustOrder);

}

How would u connect to database using .NET ? 

SqlConnection nwindConn = new SqlConnection(”Data Source=localhost; Integrated Security=SSPI;” +
“Initial Catalog=northwind”);
nwindConn.Open();

Advantage of ADO.Net ? 

o    ADO.NET Does Not Depend On Continuously Live Connections
o    Database Interactions Are Performed Using Data Commands
o    Data Can Be Cached in Datasets
o    Datasets Are Independent of Data Sources
o    Data Is Persisted as XML
o    Schemas Define Data Structures

What is the different between ASP.NET and VB.NET? 

ASP.Net is an “environment”, and VB.Net is a programming language. You can write ASP.Net pages (called “Web Forms” by Microsoft) using VB.Net (or C#, or J# or Managed C++ or any one of a number of .Net compatible languages).
Confusingly, there is an IDE that Microsoft markets called VB.Net, which allows you to write and compile programs (WinForms, WebForms, class libraries etc) written in the language VB.Net
ASP.Net is simple a library that makes it easy for you to create web applications that run against the .NET runtime (similar to the java runtime).
VB.Net is a language that compiles against the common language runtime, like C#. Any .NET compliant language can use the asp.net libraries to create web applications.
Note : Actually there is not an IDE called VB.Net.� Microsoft’s IDE is called Visual Studio.Net which can be used to manage VB.Net, C#, Eiffle, Fortran, and other languages.

How can we create custom controls in ASP.NET? 

Custom Controls can be created in either of the following 3 methods.
1. Creating as a composite control : This method uses and combines the existing controls to give a custom functionality which can be used across different projects by adding to the control library. This can provide for event bubbling from child controls to the Parent container, custom event handling and properties. The CreateChildControls function of the Control class should be overridden for creating this custom control. This can also support design time rendering of the control.
2. Deriving from an existing control : This method of creating a custom control derives from an existing ASP .Net control and customizing the properties that we need. This also can support custom event handling, properties etc.,
3. Creating a control from Scratch : This method is the one which needs maximum programming. This method needs even the HTML code for the custom controls to be written by the programmer. This may also need one to implement the IPostBackDataHandler and IPostBackEventHandler interfaces. A detailed explanation with example for this is available at Rendering Custom Controls Sample in MSDN.

How many types of validation controls are provided by ASP.NET ? 

RequiredField Validator Control,Range Validator Control, RegularExpression Validator Control,Custom Validator Control and Validation Summary Control are provided by ASP.NET.

Can you explain what is “AutoPostBack” feature in ASP.NET ? 

AutoPostBack is built into the form-based server controls, and when enabled, automatically posts the page back to the server whenever the value of the control in question is changed.

How can you enable automatic paging in DataGrid ? 

Using the Built-In Paging Controls
To use default paging, you set properties to enable paging, set the page size, and specify the style of the paging controls. Paging controls are LinkButton controls. You can choose from these types: Next and previous buttons. The button captions can be any text you want. Page numbers, which allow users to jump to a specific page. You can specify how many numbers are displayed; if there are more pages, an ellipsis ( … ) is displayed next to the numbers. You must also create an event-handling method that responds when users click a navigation control.
To use the built-in paging controlsSet the control’s AllowPaging property to true. Set the PageSize property to the number of items to display per page.
To set the appearance of the paging buttons, include a element into the page as a child of the DataGrid control. For syntax, see DataGrid Control Syntax. Create a handler for the grid’s PageIndexChanged event to respond to a paging request. The DataGridPageChangedEventsArgs enumeration contains the NewPageIndex property, which is the page the user would like to browse to. Set the grid’s CurrentPageIndex property to e.NewPageIndex, then rebind the data.

What is the difference between login controls and Forms authentication? 

Login controls are an easy way to implement Forms authentication without having to write any code. For example, the Login control performs the same functions you would normally perform when using the FormsAuthentication class—prompt for user credentials, validate them, and issue the authentication ticket—but with all the functionality wrapped in a control that you can just drag from the Toolbox in Visual Studio. Under the covers, the login control uses the FormsAuthentication class (for example, to issue the authentication ticket) and ASP.NET membership (to validate the user credentials). Naturally, you can still use Forms authentication yourself, and applications you have that currently use it will continue to run.

What is Tracing in ASP.NET ? 

ASP.NET introduces new functionality that allows you to write debug statements, directly in your code, without having to remove them from your application when it is deployed to production servers. Called tracing, this feature allows you to write variables or structures in a page, assert whether a condition is met, or simply trace through the execution path of your page or application.

How do we enable tracing ? 

Instead of enabling tracing for individual pages, you can enable it for your entire application. In that case, every page in your application displays trace information. Application tracing is useful when you are developing an application because you can easily enable it and disable it without editing individual pages. When your application is complete, you can turn off tracing for all pages at once.When you enable tracing for an application, ASP.NET collects trace information for each request to the application, up to the maximum number of requests you specify. The default number of requests is 10. You can view trace information with the trace viewer.By default, when the trace viewer reaches its request limit, the application stops storing trace requests. However, you can configure application-level tracing to always store the most recent tracing data, discarding the oldest data when the maximum number of requests is reached.To Enable Tracing for an application
1.Open your Web site’s Web.config file. If no Web.config file exists, create a new file in the root folder and copy the following into it:



2.Add a trace element as a child of the system.web element.
3.In the trace element, set the enabled attribute to true.
4.If you want trace information to appear at the end of the page that it is associated with, set the trace element’s pageOutput attribute to true. If you want tracing information to be displayed only in the trace viewer, set the pageOutput attribute to false.For example, the following application trace configuration collects trace information for up to 40 requests and allows browsers on computers other than the server of origin to display the trace viewer. Trace information is not displayed in individual pages.

What exactly happens when ASPX page is requested from Browser? 

At its core, the ASP.NET execution engine compiles the page into a class, which derives from the code behind class (which in turn derives directly or indirectly from the Page class). Then it injects the newly created class into the execution environment, instantiates it, and executes it. ASP.NET, on the other hand, can accept code in any language that is compatible with the .NET framework, because it’s compiled down natively just like other code.

How do you deploy an ASP.NET application? 

You can deploy an ASP.NET Web application using any one of the following three deployment options.1.XCOPY Deployment
2.Using the Copy Project option in VS .NET
3.Deployment using VS.NET installer

ASP.NET Configuration. 

ASP.NET Configuration
The ASP.NET configuration system features an extensible infrastructure that enables you to define configuration settings at the time your ASP.NET applications are first deployed so that you can add or revise configuration settings at any time with minimal impact on operational Web applications and servers.
The ASP.NET configuration system provides the following benefits:
* Configuration information is stored in XML-based text files. You can use any standard text editor or XML parser to create and edit ASP.NET configuration files.
* Multiple configuration files, all named Web.config, can appear in multiple directories on an ASP.NET Web application server. Each Web.config file applies configuration settings to its own directory and all child directories below it. Configuration files in child directories can supply configuration information in addition to that inherited from parent directories, and the child directory configuration settings can override or modify settings defined in parent directories. The root configuration file named systemroot\Microsoft.NET\Framework\versionNumber\CONFIG\Machine.config provides ASP.NET configuration settings for the entire Web server.
* At run time, ASP.NET uses the configuration information provided by the Web.config files in a hierarchical virtual directory structure to compute a collection of configuration settings for each unique URL resource. The resulting configuration settings are then cached for all subsequent requests to a resource. Note that inheritance is defined by the incoming request path (the URL), not the file system paths to the resources on disk (the physical paths).
* ASP.NET detects changes to configuration files and automatically applies new configuration settings to Web resources affected by the changes. The server does not have to be rebooted for the changes to take effect. Hierarchical configuration settings are automatically recalculated and recached whenever a configuration file in the hierarchy is changed. The
section is an exception.
* The ASP.NET configuration system is extensible. You can define new configuration parameters and write configuration section handlers to process them.
* ASP.NET help protect configuration files from outside access by configuring Internet Information Services (IIS) to prevent direct browser access to configuration files. HTTP access error 403 (forbidden) is returned to any browser attempting to request a configuration file directly

No comments:

Post a Comment