Breaking News

Editors Picks

Tuesday, June 29, 2010

ASP.Net FAQs

ASP.Net FAQs
What is the .Net framework?
.Net framework is the technology on which .Net applications are developed and deployed. The framework consist of three main components -
1. CLR (Comman Langauge Runtime)
2. Unified Classes (Framework Base Classes)
3. User and Program Interface (ASP.Net, Winforms)




What is CLR (Common Language Runtime)?
The Common Language Runtime is the execution engine of the .Net framework. CLR is responsible for loading and running the programs. Its unique feature is that it is designed to be common across many languages (cross-langauge interoperability).
The CLR or the Runtime provides functionality, such as exception handling, security, debugging and versioning support to any language that targets it.
The garbage collection process manages the allocation and deallocation of memory for an application. Whenever you creates an object, the CLR allocates the memory for the object from the managed heap.




What is CTS (Common Type System)?
The Common Type System provides a set of Common Data Types for use across all the programming languages targeted by the .Net framework. The CTS provides every language running on the top of the .Net framework with the base set of types as well as mechanisms for extending those types. The CTS supports a variety of types and operations found in most programmimg languages and therefore calling one language from another does not require type conversions.
Note: Every type supported by the CTS is derived from the namespace System.Object.



What is CLS (Common Language Specification)?
CLS provides the set of specification which has to be adhered by any language writer/compiler writer for the .Net framework. This insures interoperability.
Or
The Commom Language Specification defines a set of rules that enables interoperability on the .Net platform. These rules serves as a guide to third-party compiler designer and library builders. The CLS is the subset of CTS and there for the language supporting the CLS can uses others class libraries as if they azre thier own. Application Program Interface (APIs) that are designed following the rules of CLS can easily be used by all the .Net languages.




What are assemblies?
An Assembly is single deployable unit that contains all the information about the implementation of the classes, structures, interfaces and are similar to the DLL files. Both have the reusable pieces of code in the form of classes and functions. DLL needs to be registered but assemblies have its own METADATA.
An assembly stores all the information about itself. This is called METADATA and includes the name and version number of the assembly, security information, information about the dependencies and list of files that constitute the assembly.
Namespaces are also stored in the assemblies. In the .Net framework, applications are deployed in the form of assemblies.




What data types do the RangeValidator control support?
String, Integer, Double, Date and Currency.




Explain the difference between server-side and client-side code?
Server-side code executes on the server machine.
Client-side code executes in the client browser.

Can you edit data in the Repeater control?
No, It just reads and display the information from its data source.





Which template you must provide in order to display data in the Repeater control?
ItemTemplate.





How can you provide an alternating color scheme in a Repeater control?
For this you can use AlternatingItemTemplate.





From which base class do the all Web forms inherit?
Page class





How many classes a single .Net DLL can contain?
A single .Net DLL can contain as many classes as you want.





What does IsPostBack Property of the Web Form?
IsPostBack property of the page allows to check whether the page is being loaded for the first time.
False value means first time.
True means result of round trip.





What is the Code Behind feature of ASP.Net?
Code Behind feature of ASP.Net devides the ASP.Net page file into two files:
1. One contains presentation logic (.aspx file).
2. Code Behind file contains all applcation logic (.aspx.cs or .aspx.vb)

What is WYSIWYP?
WHAT YOU SEE IS WHAT YOU PRESENT.





What is @Page directive in ASP.Net?
@Page directive provides attributes that affect how the specific page built and compiled by ASP.Net engine.





What is cookies?
A cookie ia a small text file that resides on the client computer and can store the informatiom used by a web page or the entire site.





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





Can you run an ASP.Net web application without using web.config file?
Yes.





What does CommandBehavior.CloseConnection() parameter of ExecuteReader()?
It closes the connection automatically when the DataReader is closed.





Which is the process independent Session?
SqlServer
Which one is the process dependent Session?
InProc





Which are two main keywords used for authorization in web.config file?
1. allow
2. deny





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





How to get a cookie?
if (Request.Cookies["myWebSiteName"] != null)
{
string myWebSiteUrl = Request.Cookies["myWebSiteName"].Value;
}





Some ASP.Net acronyms are...
CIL - Common Intermediate Language
The language all .NET languages compile to. Equivalent to Java bytecode.
CLI - Common Language Infrastructure
The combination of the CLR, CLS, CTS and CIL
CLR - Common Language Runtime
The runtime environment itself, including garbage collection, threading etc.
CLS - Common Language Specification
A set of conventions intended to promote language interoperability.
CTS - Common Type System
The language-neutral type system used in the CLI.
IL - Intermediate Language
More commonly used abbreviation for CIL.
VES - Virtual Execution System
Another name for the CLR as far as I can tell.





Describe .Net Framework Class Library.
It consist of thousands of Pre-developed classes that can be used to build robust .Net applications.





What is garbage collection?
Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer", which is written by the user). Some garbage collectors, like the one used by .Net, compacts memory and therefore decrease your programs working set.



What is Web.Config File?
It is an optional XML File which stores configuration details for a specific ASP.Net web application.
Note: 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.




Name the configuration files supported by ASP.Net.
Configuration files are used to control and manage the behavior of a web application.
1. Machine.config
2. Web.config





What are .Net data types?
The .Net Framework provides an extensive system of types that allow you to store, manipulate and pass values between members of your application. The .Net Framework is strongly typed, meaning that objects of one type cannot be freely exchanged with objects from another type. Implicit and explicit conversions allow you to convert data types when necessary.
.Net data types can be broken down into the following subcategories:
1. Integer types
2. Floating-Point Types
3. Non-Numeric data types such as:
       Boolean
       Char
       String
       Object





What are the exceptions?
Exceptions represent a breach of an implicit assumption made within code. For example, if your code tries to access a file that is assumed to exist, but the file is missing, an exception would be thrown. However, if your code does not assume that the file exists and checks for its presence first, this scenario would not necessarily generate an exception.
Exceptions are not necessarily errors. Whether or not an exception represents an error is determined by the application in which the exception occurred. An exception that is thrown when a file is not found may be considered an error in one scenario, but may not represent an error.





Can I run my .Net Application without .Net Framework?
No you cannot. The .Net Framework must be installed in the machine on which you want to run .Net Application .





Can I run my application which was built with a newer .Net Framework ( for example .Net 2.0, .Net 3.0, .Net 3.5 ) on a machine that has a lower .Net Framework ( for example .Net Framework 1.1 ) installed?
No, you cannot, you will need to install the latest .Net Framework.





What DataReader class do in ADO.Net?
To get read-only and forward only access to data we use DataReader. The DataReader object reduces the system overhead because one row at a time is taken into memory so it is quite lightweight. To get second object connection is reconnected. We can create a DataReader object by Execute Reader() method. There are two Data Reader class one is SqlDataReader and other one is OleDbDataReader.

What is the default maximum size of the file that can be uplaoded by the ASP.Net application.
4096 KB (4MB)





What is the default executionTimeOut limit for that an ASP.Net request is allowed to run before it is automatically terminated?
90 Seconds.





How to align Text in the Textbox Control?
TextBox1.Style["text-align"]="right";





How to convert TextBox value into a DateTime variable?
DateTime dt = DateTime.Parse(TextBox1.Text);





How to programmatically set the width of the textbox control?
TextBox1.Width = Unit.Pixel(100);





How to display data in Textboxes using DataSet?
//Populate the DataSet
//...

//Display in TextBoxes using Column Name
TextBox1.Text = ds.Tables [0].Rows[0]["ProductId"].ToString ();
TextBox2.Text =ds.Tables [0].Rows[0]["ProductName"].ToString ();


//Display in TextBoxes using Column Index
TextBox1.Text = ds.Tables [0].Rows[0][0].ToString ();
TextBox2.Text =ds.Tables [0].Rows[0][1].ToString ();





Is there a TextArea in ASP.Net?
You can use the TextBox webserver control and set the TextMode = MultiLine



How to create an array of Web Server Controls?
//HTML


TextBox[] textboxes = new TextBox[5];
for (int i=0; i<5; i++)
{
textboxes[i] = new TextBox();
textboxes[i].ID = "TextBox" + i;
textboxes[i].AutoPostBack = true;
PlaceHolder1.Controls.Add(textboxes[i]);
}





Can two different programming languages be mixed in a single ASPX file?
No. ASP.Net uses parsers to strip the code from ASPX files and copy it to temporary files containing derived Page classes, and a given parser understands only one language.





Can I use custom .Net data types in a Web form?
Yes. Place the DLL containing the type in the application roots bin directory and ASP.Net will automatically load the DLL when the type is referenced. This is also what happens when you add a custom control from the toolbox to your web form.





What is the Microsoft Intermediate Language (MSIL)?
MSIL is the CPU-independent instruction set into which .Net Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.
Combined with metadata and the common type system, MSIL allows for true cross-language integration.
Prior to execution, MSIL is converted to machine code. It is not interpreted.





How can I see what assemblies are installed in the global assembly cache?
The .Net Framework ships with a windows shell extension for viewing the assembly cache. Navigating to % windir%\assembly with the Windows Explorer activates the viewer.





What is garbage collection?
Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer", which is written by the user). Some garbage collectors, like the one used by .Net, compacts memory and therefore decrease your programs working set.





How do you exclude an ASP.Net page from using Themes?
To remove themes from your page, use the EnableTheming attribute of the Page directive.

Do webservices support data reader?
No. However it does support a dataset.





What is the ExecutionTimeout in ASP.Net?
The ExecutionTimeout property indicates the maximum number of seconds a request is allowed to execute before being automatically shut down by ASP.Net. The default is 90 seconds.





What is "Literal" control in ASP.Net?
Performs the same function as "Label" control, but has no styling properties, just a Text one because it derives from Control class, not from WebControl class.





What is "AdRotator" control in ASP.Net?
Displays several images in succession, with different on displayed after each server round trip. Use the AdvertisementFile property to specify the XML file describing the iamges and the AdCreated event to perform processing before each image is sent back. You can also use target property to name a window to open when the image is clicked.





What is "Wizard" control in ASP.Net?
An advanced control used to simplify the common task of getting several pages of user input in one go. You can add multiple steps to a wizard which can be presented to a use sequentialy or non-sequentialy, and rely on this control to maintain state and so on.





What is the "MultiView" Control in ASP.Net?
A control that contains one or more View controls, where only one View is rendered at a time. The currently displayed view is specified using ActiveViewIndex, and you can detect if the view changes.





What is "View" Control in ASP.Net?
A container control, much like PlaceHolder, But designed for use as a child of MultiView. YOu can tell if given View is being displayed using Visible, or use the Activate and Deactivate events to detect changes in activation state.

What is "ImageMap" control in ASP.Net?
Like Image control, but aloows you to specify specific action to trigger if user click one or more hot spots in the image. The action to take can either be a postback or a redirection to another URL. Hot spots are supplied by embedded controls that derive from HotSpot, such as RectangleHotSpot and CircleHotSpot.





What is "ReportViewer" control in ASP.Net?
An advanced control for displaying reporting services data.





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





What is the Form-based authentication in ASP.Net?
Forms authentication generally refers to a system in which unauthenticated requests are redirected to an HTML form, using HTTP client-side redirection. Forms authentication is a good choice if your application needs to collect its own user credentials at logon time through HTML forms. The user provides credentials and submits the form. If the application authenticates the request, the system issues a form that contains the credentials or a key for reacquiring the identity. Subsequent requests are issued with the form in the request headers. They are authenticated and authorized by an ASP.NET handler using whatever validation method the application specifies.
Note that forms authentication is often used for personalization, where content is customized for a known user. In some of these cases, identification is the issue rather than authentication, so it is enough to merely store the user name in a durable form and use that form to access the users personalization information.





What is Windows-based authentication in ASP.Net?
The WindowsAuthenticationModule provider relies on IIS to provide authenticated users, using any of the mechanisms IIS supports. The provider module constructs a WindowsIdentity object. The default implementation constructs a WindowsPrincipal object and attaches it to the application context. The WindowsPrincipal object maps identities to Windows groups.
An important reason to use the Windows Authentication provider is to implement an impersonation scheme that can use any of the authentication methods that might have already been performed by IIS before passing the request to the ASP.NET application. To do this, set the authentication mode to Windows, and confirm that the impersonate element is set to true.





What is difference between Execute Reader, ExecuteNonQuery and Execute Scalar?
  • Execute Reader: Use for accessing data. It provides a forward-only, read-only, connected record set.
  • ExecuteNonQuery: Use for data manipulation, such as Insert, Update, Delete.
  • Execute Scalar: Use for retrieving 1 row 1 col. value., i.e. Single value. e.g.: for retrieving aggregate function. It is faster than other ways of retrieving a single value from DB.





What is Strongly Typed Dataset Object?
Strongly typed Dataset object allows you to create early-bound data retrieval expression.
Advantage of Strongly Typed dataset
  • It is faster than late-bound data retrieval expression.
  • Its column name is shown in intelligence as you type code.

What is DataAdapter Object?
It populates dataset from data source. It contains a reference to the connection object and opens and closes the connection automatically when reading from or writing to the database.

Example:
SqlDataAdapter daEmp = new SqlDataAdapter("select EmpID, EmpName, Salary from Employees", conn);

Fill Method
It is used to populate dataset.
example: daEmp.Fill(dsEmp,"Employee");

Update Method
It is used to update database.
example: daEmp.Update(dsEmp,"Employee");





What is DataSet Object in ADO.Net?
Dataset is a disconnected, in-memory representation of data. It can contain multiple data table from different database.

They contain multiple Datatable objects, which contain columns and rows, just like normal data base tables. You can even define relations between tables to create parent-child relationships.

Example
DataSet dsEmp = new DataSet();





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:
  1. Filling dropdownlistbox.
  2. 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 is Command Object in ADO.Net?
It allows to manipulate database by executing stored procedure or sql statements.

A SqlCommand object allows you to specify what type of interaction you want to perform with a data base.

For example, you can do select, insert, modify, and delete commands on rows of data in a data base table.
SqlCommand cmd = new SqlCommand("select * from Employees", conn);





What is the Connection Object in ADO.Net?
It establishes connection.
The connection helps identify the data base server, the data base name, user name, password, and other parameters that are required for connecting to the data base.

Example:
SqlConnection conn = new SqlConnection( "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI");





How to retrieve value of a field in a dataset?
ds.Tables["TableName"].Rows[0]["ColumnName"];





How to truncate the data in the column?
protected string TruncateData( string strNotes )
{
if (strNotes.Length > 20)
{
return strNotes.Substring(0,20) + "...";
}
else
{
return strNotes;
}
}



Read more ...

Contact Us

Name

Email *

Message *