Pages

Wednesday, December 31, 2008

SELECT Statement Execution in SQL Server

SQL Server uses the following steps to process a single SELECT statement:

1. The parser breaks SELECT statement into logical units, such as keywords, expressions, operators, and identifiers.
2. A query tree is built.
3. The query optimizer then determines the best steps that can return fastest result while consuming the fewest resources.
4. The relational engine begins executing the execution plan, requesting the storage engine to pass up data.
5. The relational engine processes the data returned from the storage engine into the result set format and returns the result set to the client.

Profiling in SQL Server

SQL Profiler captures SQL Server events from a server. The events are saved in a trace file that can be used to analyze and diagnose problem.

The different purposes of using SQL Profiler are:
It is used to find the cause of the problem by stepping through problem queries.
It is very useful to analyze the cause of slow running queries.
It can be used to tune workload of the SQL server.
It also stores security-related actions that can be reviewed by a security administrator.
SQL Profiler also supports auditing the actions performed on instances of SQL Server.

English Query in SQL Server

SQL Server English Query helps to build applications that can accept query in questions form (in English). The application passes the questions string to the English query engine. English Query then returns to the application a SQL statement or a Multi-Dimensional Expression (MDX) query that will return the answer to the user’s question.

Rename Column in SQL Server

The following sample code demonstrates how to rename a column in SQL server using the stored procedure

EXEC sp_rename @objname = '[TableName].OldColumnName',
@newname = 'NewColumnName',
@objtype = 'COLUMN'

Reverse String in C#

Normally we write FOR loop logic to reverse a string, may be because we dont explore the in-built functions of the language.

char [] strArray = TextBox1.Text.ToCharArray();
Array.Reverse( strArray );
string ReverseString = new string( strArray );
Label1.Text = ReverseString;

Create CLR Stored Procedure

With the latest version of SQL Server 2005, we have the the ability to write CLR from any .Net language.

Lets dig into more details:
I have started leaning C#, so let me show you how to write this code in C#. Please bare with me on the logic :)

Step:
1. Start Visual Studio 2005
2. Add new file
3. Select Class with C#
4. Mark the name as DemoProcCls.cs and write the below lines of code.

using System.Data.SqlServer;
using System.Data.SqlTypes;
public class DemoProcCls
{
public static void DemoProc()
{
SqlPipe sqlPipe = SqlContext.GetPipe();
sqlPipe.Send("Hello World");
}
}

i) Compile the code into assembly
You need to find out the SQL Server path of "sqlaccess.dll".

csc /target:library D:\DemoProcCls.cs /r:"sqlaccess.dll"

ii) Load the above created assembly in SQL with the use of CREATE PROCEDURE
create procedure SampleDemoProc
as external name DemoProcCls.DemoProcCls.DemoProc

and execute the stored procedure as

exec SampleDemoProc

Monday, December 29, 2008

Table Size in SQL Server

SELECT
CASE WHEN (GROUPING(sob.name)=1) THEN 'Total'
ELSE ISNULL(sob.name, 'unknown') END AS 'Table',
SUM(sys.length) AS Byte_Length
FROM sysobjects sob, syscolumns sys
WHERE sob.xtype='u'
AND sys.id=sob.id
GROUP BY sob.name
WITH CUBE

Identity Key columns in SQL Server

Use the below query to get all identity columns in the database.

SELECT SCHEMA_NAME(schema_id) AS schema_name,
t.name AS table_name,
c.name AS column_name
FROM sys.tables AS t
JOIN sys.identity_columns c ON t.OBJECT_ID = c.OBJECT_ID
ORDER BY schema_name, table_name;

NUnit

NUnit is an automated unit testing framework for .NET

NUnit is free to use with your .NET projects.

NUnit is ported from another product called JUnit, which is a unit testing framework for Java applications.

NUnit provides a class library which includes some classes and methods to help you write test scripts.

NUnit provides graphical user interface application to execute all the test scripts and show the result as a success/failure report (instead of message boxes from the test script).

NUnit is the most popular unit testing framework for .net applications.

NUnit does not create any test scripts by itself. You have to write test scripts by yourself, but NUnit allows you to use it's tools and classes to make the unit testing easier.

NUnit is an open source product. You can get this tool along with source code and modify the source code if required for your specific needs. However, 99% of the programmers do not mess with the source code. Instead, you can download only the executable and class library and implement unit test scripts for your application.

Now Microsoft offers a team collaboration system called 'Visual Studio Team System' (VSTS). This tool includes a unit testing framework also. So, eventually most of the developers may switch to VSTS instead of NUnit. However, NUnit will continue to exist because it is free and easy to use.

Microsoft Visual Studio 2010

Microsoft Visual Studio 2010 and the .NET Framework 4.0 are the next generation development tools and platform for Windows Vista, the 2007 Office System, and the Web.



Visual Studio 2010 and the .NET Framework 4.0 mark the next generation of developer tools from Microsoft. Designed to address the latest needs of developers, Visual Studio delivers key innovations in the following pillars:

Democratizing Application Lifecycle Management
Application Lifecycle Management (ALM) crosses many roles within an organization and traditionally not every one of the roles has been an equal player in the process. Visual Studio Team System 2010 continues to build the platform for functional equality and shared commitment across an organization’s ALM process.

Enabling emerging trends
Every year the industry develops new technologies and new trends. With Visual Studio 2010 and .NET Framework 4.0, Microsoft delivers tooling and framework support for the latest innovations in application architecture, development and deployment.

Inspiring developer delight
Ever since the first release of Visual Studio, Microsoft has set the bar for developer productivity and flexibility. Visual Studio 2010 continues to deliver on the core developer experience by significantly improving upon it for roles involved with the software development process. .NET Framework 4.0 contains numerous improvements that make it easier to develop powerful and compelling applications.

Riding the next generation platform wave
Microsoft continues to invest in the market leading operating system, productivity application and server platforms to deliver increased customer value in these offerings. With Visual Studio 2010 and .NET Framework 4.0 customers will have the tooling support and the platform support needed to create amazing solutions around these technologies.


Check out the below link for more information
http://www.microsoft.com/downloads/details.aspx?FamilyId=922B4655-93D0-4476-BDA4-94CF5F8D4814&displaylang=en

http://www.microsoft.com/visualstudio/products/2010/default.mspx

ASP.Net 2010

Next generation of developer tool from Microsoft is available now (CTP version)

Some Links for ASP.Net 2010(4.0) explaining about the features of .NET Framework 4.0
http://msdn.microsoft.com/en-us/vs2008/products/cc948977.aspx

http://www.codeproject.com/KB/cs/concept_ide.aspx

http://blogs.msdn.com/somasegar/archive/2008/09/29/what-s-next-for-visual-studio-and-net-fx.aspx

You can also download the Beta Version of ASP.Net 2010(v4.0).

https://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=9790

Yet to lay my hands on it. But Can't wait.

Cloud Computing

Cloud computing is a computing paradigm in which tasks are assigned to a combination of connections, software and services accessed over a network. This network of servers and connections is collectively known as "the cloud." Computing at the scale of the cloud allows users to access supercomputer-level power. Using a thin client or other access point, like an iPhone, BlackBerry or laptop, users can reach into the cloud for resources as they need them.

check out the below link
http://searchenterprisedesktop.techtarget.com/sDefinition/0,,sid192_gci1287881,00.html#

Avoid Postback

I had to show an alert on a button click,but when ever i "OK" it always postsback.

To avoid such a thing simply we can use HTML Control.

have the following code in code-behind window.

Button.Attributes.Add("onclick","alert('Are You Sure ??');return false;");

This will prevent postback....

Debug Java Script

Are you in need of debugging the java script code and since VS dont support this by default, this could be done by using multiple alerts at the place where we need to know the obj values... But this is tricky to handle...

So Go for debugger; option which enables your browser to ask for debugging Javascript coding And this debugging could be done with editors of VS (From VS 2003).

example -
function(value)
{
debugger;
var test;
if(value==1)
return true;
else
return false;
}

Note: For this ur browser has to be enabled for script debugging.
Goto Tools-> Options -> Internet Options[Advanced Tab].Ensure Disable script debugging options are unselected.

State Management Interview Questions

What is ViewState?
ViewState allows the state of objects (serializable) to be stored in a hidden field on the page. ViewState is transported to the client and back to the server, and is not stored on the server or any other external source. ViewState is used the retain the state of server-side objects between postabacks.

What is the lifespan for items stored in ViewState?
Item stored in ViewState exist for the life of the current page. This includes postbacks (to the same page).

What does the "EnableViewState" property do? Why would I want it on or off?
It allows the page to save the users input on a form across postbacks. It saves the server-side values for a given control into ViewState, which is stored as a hidden value on the page before sending the page to the clients browser. When the page is posted back to the server the server control is recreated with the state stored in viewstate.

What are the different types of Session state management options available with ASP.NET?
ASP.NET provides In-Process and Out-of-Process state management. In-Process stores the session in memory on the web server. This requires the a "sticky-server" (or no load-balancing) so that the user is always reconnected to the same web server. Out-of-Process Session state management stores data in an external data source. The external data source may be either a SQL Server or a State Server service. Out-of-Process state management requires that all objects stored in session are serializable.

Tracing in ASP.NET

ASP.NET tracing enables you to view diagnostic information about a single request for an ASP.NET page. ASP.NET tracing enables you to follow a page's execution path, display diagnostic information at run time, and debug your application. ASP.NET tracing can be integrated with system-level tracing to provide multiple levels of tracing output in distributed and multi-tier applications.

ASP.NET tracing offers the following features:

Debugging statments You can write debug statements in your code without having to remove them from your application when it is deployed to production servers. You can also write variables or structures in a page and trace through the execution path of your page or application.

Integrated tracing functionality You can route messages emitted by the System.Diagnostics..::.Trace class to ASP.NET tracing output, and route messages emitted by ASP.NET tracing to System.Diagnostics..::.Trace. You can also forward ASP.NET instrumentation events to System.Diagnostics..::.Trace. For more information, see Walkthrough: Integrating ASP.NET Tracing with System.Diagnostics Tracing.

Programmatic access to trace messages You can access and manipulate trace messages from your code for finer control over the format of trace messages or for additional processing that you require.

Application-level tracing The application-level tracing option lets you view the most recent tracing data available without restarting a tracing session and without increasing the amount of tracing data that the server must store. The most recent tracing data is displayed, and older tracing data is discarded.

log into the below link for more information:
http://msdn.microsoft.com/en-us/library/bb386420.aspx

Thursday, December 11, 2008

Ajax examples

Ajax allows for rich-internet applications that mimic the responsiveness and complex user interfaces typically associated with desktop applications. Moving applications to the web browser opens many possibilities, including the ability to save user data, connecting with other users for collaboration and sharing, and making deployment and using the application easier since web browsers are standard-issue with most computers regardless of operating system.

If you’re interested in expanding your understanding of Ajax techniques and practices, check out these 25 hand-picked Ajax articles and tutorials that outline various methods and concepts involved in the development of Ajax-based applications.

Please check out below link to get the 25 hand-picked Ajax articles and tutorials

http://sixrevisions.com/ajax/ajax_techniques/

ASP.NET Caching Part 2

Data Caching
So we know that we can cache an entire page, or a fragment of a page by caching down to the user control level. Wouldn’t it be great if we could cache down to the object level? The good news is you can with ASP.NET Data caching.

The cache consists of a dictionary collection that is private to each application in memory. To insert items in the cache simply provide the collection with a unique name:

Cache["USER_id"] = myObject;

Retrieving the object form the cache:

myObj = (MyObj)Cache["USER_id"];

It is a good time to point out that you should always remember to check for null, and be sure to caste to your datatype.

Cache Configuration
If you are familiar with how caching worked in ASP.NET 1.0, you realize that managing all the cache directions for all your pages could potentially get out of hand. ASP.NET 2.0 introduces Cache Profiles that helps you centrally manage your cache. Cache settings can be inherited by your pages, and overridden if required by using the OutputCache directive.

The page directive looks pretty much the same, expect this time it references a cache profile that you defined in your web.config file.

<%@ Page Language=”C#” %>
<%@ OutputCache CacheProfile=”testCacheProfile” VaryByParam=”none” %>













So each and every page that references the ‘testCacheProfile’ can be centrally managed in the web.config, this means that any changes to the cache settings in the web.config file will be automatically changed on all your referenced pages.

ASP.NET Caching Part 1

There are various kinds of cachings available in ASP.NET. In fact i would say Caching is very cool feature in .net to improve application performance.

Different kinds of caching that you can use in your web applications


Output Caching
Performance is improved in an ASP.NET application by caching the rendered markup and serving the cached version of the markup until the cache expires. For example, if you have a page that displays user information from a database, caching will help improve performance by serving the page from memory instead of making a connection to the database on each page request.

You can cache a page by using the OutputCache API or simply by using the @OutputCache directive.

<%@ Page Language=”C#” %>
<%@ OutputCache Duration=”30” VaryByParam=”none” %>

The above cache directive will cache the page for 30 minutes.

So output caching is great for when you want to cache an entire page.


Fragment Caching
In many situations caching the entire page just isn’t going to cut it, for some reason or another you require specific sections of the page to display live information. One way to improve performance is to analyze your page and identify objects that require a substantial overhead to run. You can build a list of these objects that are expensive to run, and then cache them for a period of time using fragment caching.

For example, say your page default.aspx consists of three user controls. After looking over the code, you identified that you can cache one of them. You can simply add the caching directive to the top of the user control:

<%@ Control %>
<%@ OutputCache Duration=”15” VaryByParam=”none” %>

Now keep in mind that the actual page that contains the control is not cached, only the user control. This means that the default.aspx page will be rendered each and every page request, but the user control is only ‘run’ every 15 minutes.



Keep watching for more information

Wednesday, December 10, 2008

WCF Fundamentals

As the Services need to communicate with clients by sending and receiving messages, naturally in WCF consists of three main concepts:
• Services: Programs that respond to clients. They can send or receive messages.
• Clients: Programs that ask for a service. They can send or receive messages.
• Intermediaries: Programs that works as link between services and clients, for example, they can work as a firewall or can rout messages.
As a developer you will be writing the clients and services. WCF generally takes care of the intermediaries and the messaging. A service can have more than one client and each service can be a client of another service. As you can see WCF is mainly about communication between services provided over the web, you will come across some important concepts like Channels, Bindings, Contracts, Behaviors, Addresses and Endpoints time and again.
Windows Communication Foundation has five-layer architecture. Developers with different skills generally work on different layers. These layers top to down are:
• Application Layer: the application is located in the topmost layer.
• Contracts Layer: below the application layer is the contracts layer where the data and message contracts and bindings and policies are present. In this level services describe themselves to clients.
• Runtime Layer: this layer loads the services and defines the Behaviors.
• Messaging Layer: as the name suggests this layer is responsible for communication between services and deals with different channels and encoding.
• Hosting Layer: this layer contains the host services. You can host a service in two ways.
? You can host a service in Internet Information Services (IIS). This way your services are started and stopped automatically.
? You can create executable files (.EXE) for services and start and stop them manually by writing codes.
There are three programming approaches in Windows Communication Foundation:
• Imperative: You use programming codes in different languages to accomplish a task.
• Configuration Based: You use configuration files to do things.
• Declarative: You use attributes to declare something.
Generally, contracts and behaviors are declared using attributes, configure endpoints, security and some other settings in configuration files and service methods logic are implemented in codes. There are typed services and untyped services. In typed services normal objects and data types are passed and returned, and in untyped services the messages are passed and returned in the lower level.
If you are working with Visual Studio 2005, then you will have to install Visual Studio 2005 xtensions for .NET Framework 3.0 WCF and WPF. After installing this package, you will have new project templates in your Visual Studio to start developing for Windows Communication Foundation.
And if you are working with Visual Studio 2008, you get the new templates for WCF services, in the create web site dialog box.

ASP.Net Interview Questions - Part 7

Q1. Explain the differences between Server-side and Client-side code?
Ans. Server side code will execute at server (where the website is hosted) end, & all the business logic will execute at server end where as client side code will execute at client side (usually written in javascript, vbscript, jscript) at browser end.

Q2. What type of code (server or client) is found in a Code-Behind class?
Ans. Server side code.

Q3. How to make sure that value is entered in an asp:Textbox control?
Ans. Use a RequiredFieldValidator control.

Q4. Which property of a validation control is used to associate it with a server control on that page?
Ans. ControlToValidate property.

Q5. How would you implement inheritance using VB.NET & C#?
Ans. C# Derived Class : Baseclass
VB.NEt : Derived Class Inherits Baseclass

Q6. Which method is invoked on the DataAdapter control to load the generated dataset with data?
Ans. Fill() method.

Q7. What method is used to explicitly kill a user's session?
Ans. Session.Abandon()

Q8. What property within the asp:gridview control is changed to bind columns manually?
Ans. Autogenerated columns is set to false

Q9. Which method is used to redirect the user to another page without performing a round trip to the client?
Ans. Server.Transfer method.

Q10. How do we use different versions of private assemblies in same application without re-build?
Ans.Inside the Assemblyinfo.cs or Assemblyinfo.vb file, we need to specify assembly version.
assembly: AssemblyVersion

ASP.Net Interview Questions - Part 6

Qs. What is shared and private assembly ?
Answer Shared assemblies are accessed by more than one application and they are stored in GAC. private assemblies are accessed
by only one application and they are stored in application directory and one of its subdirectory.

Qs. What is strong name and which tool is used for this ?
Answer If you want to design an assembly which is used by more than one application then that assembly should be assigned
a strong name. sn.exe is used to generate a strong name.(Note:Once the strongname is given to an assembly it no longer remians private)
Answer Strong Name is to be assigned to shared assembly. when more then one application is going to use that dll/assembly,
that assembly has to assign a strong name and has to be place in GAC(Global Assembly Cache).

Qs. Difference between and
Answer u can declare ur database connection in connection string and u can declare all ur application settings in appsettings like ur service url etc.
In you can store any key and value pairs where as in the you can have only the name and connectionstring attribute.
is used before connection string we use it to set the applicstion setting so that program run successfully,but
is used to make the or establish the connection.

Qs. Can two application one using private assembly and other using Shared assembly be stated as a side-by-side executables?
Answer Side-by-side execution is the ability to run multiple versions of an application or component on the same computer.
You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time.
Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side executables.

ASP.Net Interview Questions - Part 5

Can you give an example of what might be best suited to place in the
Application_Start and Session_Start subroutines?

Ans :The Application_Start event is guaranteed to occur only once throughout the lifetime of the application. It’s a good place to initialize global variables. For example, you might want to retrieve a list of products from a database table and place the list in application state or the Cache object. SessionStateModule exposes both Session_Start and Session_End events..


What are ASP.NET Web Forms? How is this technology different than what is
available though ASP?

Ans :Web Forms are the heart and soul of ASP.NET. Web Forms are the User Interface (UI) elements that give your Web applications their look and feel. Web Forms are similar to Windows Forms in that they provide properties, methods, and events for the controls that are placed onto them. However, these UI elements render themselves in the appropriate markup language required by the request, e.g. HTML. If you use Microsoft Visual Studio .NET, you will also get the familiar drag-and-drop interface used to create your UI for your Web application..


How does VB.NET/C# achieve polymorphism?

Ans :By using Abstract classes/functions..


Can you explain what inheritance is and an example of when you might use it?

Ans :Inheritance is a fundamental feature of an object oriented system and it is simply the ability to inherit data and functionality from a parent object. Rather than developing new objects from scratch, new code can be based on the work of other programmers, adding only new features that are needed..


What’s an assembly?

Ans :Assemblies are the building blocks of .NET Framework applications; they form the fundamental unit of deployment, version control, reuse, activation scoping, and security permissions. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. An assembly provides the common language runtime with the information it needs to be aware of type implementations. To the runtime, a type does not exist outside the context of an assembly..


Describe the difference between inline and code behind - which is best in a
loosely coupled solution?

Ans :ASP.NET supports two modes of page development: Page logic code that is written inside "script runat=server" blocks within an .aspx file and dynamically compiled the first time the page is requested on the server. Page logic code that is written within an external class that is compiled prior to deployment on a server and linked "behind" the .aspx file at run time..


Explain what a diffgram is, and a good use for one?

Ans :A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order..


Where would you use an iHTTPModule, and what are the limitations of
anyapproach you might take in implementing one?

Ans :One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a
custom HTTP module..

ASP.Net Interview Questions - Part 4

What is delay signing?

Ans :Delay signing allows you to place a shared assembly in the GAC by signing the assembly with just the public key. This allows the assembly to be signed with the private key at a later stage, when the development process is complete and the component or assembly is ready to be deployed. This process enables developers to work with shared assemblies as if they were strongly named, and it secures the private key of the signature from being accessed at different stages of development..


What’s the difference between code-based security and role-based security?
Which one is better?

Ans :Code security is the approach of using permissions and permission sets for a given code to run. The admin, for example, can disable running executables off the Internet or restrict access to corporate database to only few applications. Role-based security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account. There’s no better, or 100%
thumbs-up approach, depending on the nature of deployment, both code-based and role-based security could be implemented to an extent..


How can you work with permissions from your .NET application?

Ans :You can request permission to do something and you can demand certain permissions from other apps. You can also refuse permissions so that your app is not inadvertently used to destroy some data..


How can C# app request minimum permissions?

Ans :Using System.Security.Permissions; [assembly:FileDialogPermissionAttribute(SecurityAction.RequestMinimum, Unrestricted=true)].


What’s a code group?

Ans :A code group is a set of assemblies that share a security context..


What’s the difference between authentication and authorization?

Ans :Authentication happens first. You verify user’s identity based on credentials. Authorization is making sure the user only gets access to the resources he has credentials for..


What are the authentication modes in ASP.NET?

Ans :None, Windows, Forms and Passport..


Are the actual permissions for the application defined at run-time or compiletime?

Ans :The CLR computes actual permissions at runtime based on code group membership and the calling chain of the code..


Explain the differences between Server-side and Client-side code?

Ans :Server side scripting means that all the script will be executed by the server and interpreted as needed. ASP doesn’t have some of the functionality like sockets, uploading, etc. For these you have to make a custom component usually in VB or VC++. Client side scripting means that the script will be executed immediately in the browser such as form field validation, clock, email validation, etc. Client side scripting is usually done in VBScript or JavaScript. Download time, browser compatibility, and visible code - since JavaScript and VBScript code is included in the HTML page, then anyone can see the code by viewing the page source. Also a possible security hazards for the client computer..


Should validation (did the user enter a real date) occur server-side or client-side? Why?

Ans :Client-side validation because there is no need to request a server side date when you could obtain a date from the client machine..


What does the "EnableViewState" property do? Why would I want it on or off?

Ans :Enable ViewState turns on the automatic state management feature that enables server controls to re-populate their values on a round trip without requiring you to write any code. This feature is not free however, since the state of a control is passed to and from the server in a hidden form field. You should be aware of when ViewState is helping you and when it is not. For example, if you are binding a control to data on every round trip (as in the datagrid example in tip #4), then you do not need the control to maintain it’s view state, since you will wipe out any re-populated data in any case. ViewState is enabled for all server controls by default. To disable it, set the EnableViewState property of the control to false..

ASP.Net Interview Questions - Part 3

How do you display an editable drop-down list?

Ans : Displaying a drop-down list requires a template column in the grid. Typically, the ItemTemplate contains a control such as a data-bound Label control to show the current value of a field in the record. You then add a drop-down list to the EditItemTemplate. In Visual Studio, you can add a template column in the Property builder for the grid, and then use standard template editing to remove the default TextBox control from the EditItemTemplate
and drag a DropDownList control into it instead. Alternatively, you can add the template column in HTML view. After you have created the template column with the drop-down list in it, there are two tasks. The first is to populate the list. The second is to preselect the appropriate item in the list — for example, if a book’s genre is set to “fiction,” when the drop-down list displays, you often want “fiction” to be preselected.


How do you check whether the row data has been changed?

Ans :The definitive way to determine whether a row has been dirtied is to handle the changed event for the controls in a row. For example, if your grid row contains a TextBox control, you can respond to the control’s TextChanged event. Similarly, for check boxes, you can respond to a CheckedChanged event. In the handler for these events, you maintain a list of the rows to be
updated. Generally, the best strategy is to track the primary keys of the affected rows. For example, you can maintain an ArrayList object that contains the primary keys of the rows to update..


What do you know about .NET assemblies?

Ans: Assemblies are the smallest units of versioning and deployment in the .NET application. Assemblies are also the building blocks for programs such as Web services, Windows services, serviced components, and .NET remoting applications.


What’s the difference between private and shared assembly?

Ans : Private assembly is used inside an application only and does not have to be identified by a strong name. Shared assembly can be used by multiple applications and has to have a strong name..


What’s a strong name?
Ans :A strong name includes the name of the assembly, version number, culture identity, and a public key token..


How can you tell the application to look for assemblies at the locations other than its own install?

Ans :Use the directive in the XML .config file for a given application.
should do the trick. Or you can add additional search paths in the Properties box of the deployed application..


How can you debug failed assembly binds?

Ans :Use the Assembly Binding Log Viewer (fuslogvw.exe) to find out the paths searched..


Where are shared assemblies stored?

Ans :Global Assembly Cache..


How can you create a strong name for a .NET assembly?

Ans :With the help of Strong Name tool (sn.exe)..


Where’s global assembly cache located on the system?

Ans :Usually C:\winnt\assembly or C:\windows\assembly..


Can you have two files with the same file name in GAC?

Ans :GAC is a very special folder, and while normally you would not be able to place two files with the same name into a Windows folder, GAC differentiates by version number as well, so it’s possible for MyApp.dll and MyApp.dll to co-exist in GAC if the first one is version 1.0.0.0 and the second one is 1.1.0.0..

ASP.Net Interview Questions - Part 2

Where do you store the information about the user’s locale?

Ans :System.Web.UI.Page.Culture.


What’s the difference between Codebehind="MyCode.aspx.cs" and
Src="MyCode.aspx.cs"?

Ans : CodeBehind is relevant to Visual Studio.NET only.


What’s a bubbled event?

Ans :When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button,row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.. Suppose you want a certain ASP.NET function executed on MouseOver over a
certain button.


Where do you add an event handler?

Ans :It’s the Attributesproperty, the Add function inside that property. So
btnSubmit.Attributes.Add("onMouseOver","someClientCode();") A simple”Javascript:ClientCode();” in the button control of the .aspx page will attach the handler (javascript function)to the onmouseover event..


What data type does the RangeValidator control support?

Ans :Integer,String and Date..


Where would you use an iHTTPModule, and what are the limitations of any
approach you might take in implementing one?

Ans :One of ASP.NET’s most useful features is the extensibility of the HTTP pipeline, the path that data takes between client and server. You can use them to extend your ASP.NET applications by adding pre- and post-processing to each HTTP request coming into your application. For example, if you wanted custom authentication facilities for your application, the best technique would be to intercept the request when it comes in and process the request in a
custom HTTP module..


Explain what a diffgram is and a good use for one?

Ans :A DiffGram is an XML format that is used to identify current and original versions of data elements. The DataSet uses the DiffGram format to load and persist its contents, and to serialize its contents for transport across a network connection. When a DataSet is written as a DiffGram, it populates the DiffGram with all the necessary information to accurately recreate the contents, though not the schema, of the DataSet, including column values from both the Original and Current row versions, row error information, and row order..


What is datagrid?

Ans :The DataGrid Web server control is a powerful tool for displaying information from a data source. It is easy to use; you can display editable data in a professional-looking grid by setting only a few properties. At the same time, the grid has a sophisticated object model that provides you with great flexibility in how you display the data..


What’s the difference between the System.Web.UI.WebControls.DataGrid and and
System.Windows.Forms.DataGrid?

Ans :The Web UI control does not inherently support master-detail data structures. As with other Web server controls, it does not support two-way data binding. If you want to update data, you must write code to do this yourself. You can only edit one row at a time. It does not
inherently support sorting, although it raises events you can handle in order to sort the grid contents. You can bind the Web Forms DataGrid to any object that supports the IEnumerable interface. The Web Forms DataGrid control supports paging. It is easy to customize the appearance and layout of the Web Forms DataGrid control as compared to the Windows Forms one.


How do you customize the column content inside the datagrid?

Ans : If you want to customize the content of a column, make the column a template column. Template columns work like item templates in the DataList or Repeater control, except that you are defining the layout of a column rather than a row.


How do you apply specific formatting to the data inside the cells?

Ans :You cannot specify formatting for columns generated when the grid’s
AutoGenerateColumns property is set to true, only for bound or template columns. To format, set the column’s DataFormatString property to a string-formatting expression suitable for the data type of the data you are formatting.


How do you hide the columns?

Ans :One way to have columns appear dynamically is to create them at design time, and then to hide or show them as needed. You can do this by setting a column’s Visible property.

ASP.Net Interview Questions - Part 1

How many languages .NET is supporting now?

Ans : When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl,etc. The site DotNet Languages. Net says 44 languages are supported..


How is .NET able to support multiple languages?

Ans : A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language..


How ASP .NET different from ASP?

Ans : Scripting is separated from the HTML, Code is compiled as a DLL, and these DLLs can be executed on the server.


What is smart navigation?

Ans : The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.


What is view state?

Ans: The web is stateless. But in ASP.NET, the state of a page is maintained in the page itself automatically. How? The values are encrypted and saved in hidden controls. This is done automatically by the ASP.NET. This can be switched off / on for a single control.


How do you validate the controls in an ASP .NET page?

Ans : Using special validation controls that are meant for this. We have Range Validator, Email Validator.


Can the validation be done in the server side? Or this can be done only in the
Client side?

Ans :Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done..


How to manage pagination in a page?

Ans :Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.


What is ADO .NET and what is difference between ADO and ADO.NET?

Ans :ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch..


Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process ?

Ans :inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe..


What’s the difference between Response.Write() and Response.Output.Write()?

Ans :The latter one allows you to write formatted output..


What methods are fired during the page load?

Ans :Init() - when the page is instantiated, Load() - when the page is loaded into server memory, PreRender() - the brief moment before the page is displayed to the user asHTML, Unload() - when page finishes loading..


Where does the Web page belong in the .NET Framework class hierarchy?

Ans :System.Web.UI.Page