Monday, December 10, 2007

Event Vs Delegate:::::::::::

An event is an event. A "delegate" assigns a particular event handler to an object instance. Thus, when an object event happens, the proper procedure/method is called.

An example might help. I frequently code things so that a single method is called for all instances of a class. No matter which button is clicked, call my generic "button_click" method. That method will use the event arguments to determine which button was actually clicked.In order to assign all button click events to a single method, I have to code the delegates.

ASPNET interview questions::::::::::
http://www.dotnetquestion.com/DOTNETFRAMEWORK/Dot%20Net%20Faramework%20Interview%20questions%201-5.html

Why Interface:::
An interface is a contract. When you design an interface, you're saying "if you want to provide this capability, you must implement these methods, provide these properties and indexers, and support these events." The implementer of the interface agrees to the contract and implements the required elements.

NOTE::::::::
foreach_(_) implements both IEnumerable and IEnumerator

C# .net questions::::
http://p3net.mvps.org/CHowSharp/2007/March/03182007.aspx

Authentication::::::::: @ User Level
Authorization:::::::::: @ Account Level

What is the difference bw hosting a application using virtual directory and without creating the virtual directory?

using virtual directory, v neednt keep updating the absolute path if at all there is ne change, but hosting it directly, whene ever there is a change in the path, v need to update it accordingly

All abt masterpages:::::::::::::
http://www.codeproject.com/aspnet/ImplementMasterPages.asp
FAQs' on .net

If I return out of a try/finally in C#, does the code in the finally-clause run? - Yes. The code in the finally always runs. If you return out of the try block, or even if you do a “goto” out of the try, the finally block always runs

How do you specify a custom attribute for the entire assembly (rather than for a class)? - Global attributes must appear after any top-level using clauses and before the first type or namespace declarations. An example of this is as follows:

_using _System;
_[_assembly _:_ _MyAttributeClass_]_ _class X _{_}_

Note that in an IDE-created project, by convention, these attributes are placed in AssemblyInfo.cs.

How do you mark a method obsolete? -
_[_Obsolete_]_ _public _int _Foo_(_)
_{..._}
or
_[_Obsolete_(_\"This is a message describing why this method is obsolete_\_")] _public _int _Foo_(_) _{...}
Note: The O in Obsolete is always capitalized.

How do you directly call a native function exported from a DLL? - Here’s a quick example of the DllImport attribute in action:

_using _System._Runtime._InteropServices; _\_
_class _C
{
_[_DllImport_(_\_"user32.dll_\_")_]
_public _static _extern _int _MessageBoxA_(_int _h, _string _m, _string _c, _int _type_);
_public _static _int _Main()
{ _return _MessageBoxA_(_0, _\_"Hello World!_\_", _\_"Caption_\_", 0);
}
}

This example shows the minimum requirements for declaring a C# method that is implemented in a native DLL. The method C.MessageBoxA() is declared with the static and external modifiers, and has the DllImport attribute, which tells the compiler that the implementation comes from the user32.dll, using the default name of MessageBoxA. For more information, look at the Platform Invoke tutorial in the documentation.

Which of these statements correctly declares a two-dimensional array in C#?
int[,] myArray;

How does assembly versioning in .NET prevent DLL Hell?
.NET allows assemblies to specify the name AND the version of any assemblies they need to run.

In the NUnit test framework, which attribute must adorn a test class in order for
it to be picked up by the NUnit GUI?
TestFixtureAttribute

Which of the following operations can you NOT perform on an ADO.NET DataSet?
A DataSet can be synchronised with the database. [CAN]
A DataSet can be synchronised with a RecordSet. [CANNOT]
A DataSet can be converted to XML. [CAN]
You can infer the schema from a DataSet. [CAN]

How can you tell the application to look for assemblies at the locations other than its own install?
Use the directive in the XML .config file for a given application.
_<_probing _privatepath_="_”_c:\mylibs;">
should do the trick.
Or you can add additional search paths in the Properties box of the deployed application.

What is delay signing?
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
All abt Delegates:::::::::::
http://www.codeproject.com/csharp/event_fundamentals.asp#3.1DefinitionandUsageofDelegates3

All abt Web.config file::::::::
http://www.dotnethero.com/hero/application/webconfig.aspx?nmx=5_1

All abt global.asax file:::::::::::
http://www.dotnethero.com/hero/application/globalasax.aspx?nmx=5_2

Dynamic Loading of User Control with ViewState Preserved:::::::::::::::
http://www.aspnet4you.com/Articles.aspx?ArticleID=5032

To Copy a datatable 2 another:::::::::::
http://www.dotnet247.com/247reference/msgs/48/243916.aspx

To add a new column @ a particular index::::::
http://blah.winsmarts.com/2006/05/20/loadcontrol-a-usercontrol--and-pass-in-constructor-parameters.aspx
What’s a bubbled event? ::::::::::::::::
a bubbled event is the process of moving an event up the control hierarchy, from a control low in the hierarchy, such as a button in the datagrid ans prelocating it upto an ancestor control

How function overriding works in C# and what is shadowing?:::::::::::
This article explains what is Shadowing and how to achieve shadowing in C#? I mean overriding concept using override and new keywords of C#

Introduction
This article will introduce you with a very good concept of shadowing in C#.
Shadowing is a concept of polymorphism usage in Object Oriented Programming.

What is Shadowing?
Shadowing is a concept of polymorphism usage in Object Oriented Programming.This is a concept related to over-riding functions at run-time or making a shadow of the object's methods in the inherited classes.

Implementation of override to override a method
Suppose you have a base class ClassA in which you have written a method MethodA. Now, if you want to inherit this class in a ClassB and use MethodA then the MethodA declared in ClassA will be used but if you override this method in your inherited class classB then it will be over-ridden and the implementation of classB will be used whenever we use it from classB and the implementation of classA will be used whenever we use it from a instance of classA.

_#_define _TRACE
_using _System;
_using _System._Diagnostics;
_using _System._IO;

_public _class _ClassA
{
_public _virtual _void _MethodA_()
{
_Trace._WriteLine_(_"_BaseClass MethodA_"_);
}
}

_public _class _ClassB :_ClassA
{
_public _override _void _MethodA()
{
_Trace._WriteLine_(_"_SubClass MethodA overridden_"_);
}
}

//implementation class for using the above defined classes

_public _class _TopLevel
{
_static _void _Main(_string[] _args)
{
_TextWriter _tw = _Console._Out;
_Trace._Listeners._Add_(_new _TextWriterTraceListener_(_tw_)_);
_ClassA _obj = _new_ _ClassB(); \
_obj._MethodA(); // Output will be “Subclass MethodA overridden”
}
}

Shadowing instead of overriding
Upto now the code shown was for overriding a base class method with the child class method, But what will happen If you want to provide the base class behaviour instead, use the new directive, with or without virtual at the base class Is this possible in C#? Yes, it is and that is the concept of shadowing in C# using a keyword "new' which is a modifier used instead of "override".

Check out in the code below
_public _class _ClassA
{ _public _virtual _void _MethodA()
{ _Trace._WriteLine_(_"_BaseClass MethodA"_)_;
}
}

_public _class _ClassB :_ClassA
{
_public _new _void _MethodA()
{
_Trace._WriteLine_(_"_SubClass MethodA overridden_"_);
}
}

//implementation class for using the above defined classes

_public _class _TopLevel
{
_static _void _Main_(_string[] _args)
{
_TextWriter _tw = _Console._Out;
_Trace._Listeners._Add_(_new _TextWriterTraceListener_(_tw_)_);
_ClassA _obj = _new _ClassB_();
_obj._MethodA_(); // Outputs “Class A Method"
_ClassB _obj1 = _new _ClassB();
_obj._MethodA_(); // Outputs “SubClass ClassB Method”
}
}
ASP.NET Internals – IIS and the Process Model:::::::::::::::::::
http://dotnetslackers.com/articles/iis/ASPNETInternalsIISAndTheProcessModel.aspx#162
Page level Tracing::::::::::::::::::



ASP.NET tracing can be enabled on a page-by-page basis by adding "_Trace=_true" to the Page directive in any ASP.NET page:



<_%_@ _language="_" _trace="_" _tracemode_ =" _" _inherits =" _" _codefile="_">



Additionally, you can add the TraceMode attribute that sets SortByCategory or the default,
SortByTime. You can use SortByTime to see the methods that take up the most CPU time for your application. You can enable tracing programmatically using the Trace.IsEnabled property.




Application Tracing::::::::::::::::::::::You can enable tracing for the entire application by adding tracing settings in web.config. In below example, _pageOutput=_"_false" and requestLimit=_"_20" are used, so trace information is stored for 20 requests, but not displayed on the page because pageOutput attribute is set to false.



<_configuration>

<_appsettings/>

<_connectionstrings/>

<_system._web>

<_compilation _debug="_">

<_authentication _mode="_">

<_trace _enabled ="_" _pageoutput ="_" _requestlimit ="_" _tracemode ="_">
<_/_system._web>

<_/_configuration>

The page-level settings take precedence over settings in Web.config, so if enabled=_"_false" is set in Web.config but trace=_"_true" is set on the page, tracing occurs.

Viewing Trace Data::::::::::::
Tracing can be viewed for multiple page requests at the application level by requesting a special page called trace.axd. When ASP.NET detects an HTTP request for trace.axd, that request is handled by the TraceHandler rather than by a page.

Create a website and a page, and in the Page_Load event, call Trace.Write(). Enable tracing in Web.config as shown below.

<_system.web>
<_compilation _debug="_">
<_authentication _mode="_">
<_trace _enabled ="_" _pageoutput ="_">


_protected _void _Page_Load_(_object _sender, _EventArgs _e)
{
_System.Diagnostics.Trace.Write_(_"This is Page_Load method!"_);
}


Trace.axd::::::::::: Page output of tracing shows only the data collected for the current page
request. However, if you want to collect detailed information for all the requests then we need to use Trace.axd. We can invoke Trace.axd tool for the application using the following URL
http://localhost/application-name/trace.axd. Simply replace page name in URL with Trace.axd. That is, in our case. We should use following URL (Address bar) for our application as shown below.
What are the basic differences between user controls and custom controls?

Now that you have a basic idea of what user controls and custom controls are and how to create them, let's take a quick look at the differences between the two.

Deployment::::::::::: Designed for single-application scenarios
Deployed in the source form (.ascx) along with the source code of the application


If the same control needs to be used in more than one application, it introduces redundancy and
maintenance problems Designed so that it can be used by more than one application


Deployed either in the application's Bin directory or in the global assembly cache

Distributed easily and without problems associated with redundancy and maintenance

Creation::::::::::::::: Creation is similar to the way Web Forms pages are created; well-suited for rapid application development (RAD)

Writing involves lots of code because there is no designer support

Content:::::::::::::::: A much better choice when you need static content within a fixed layout, for example, when you make headers and footers

More suited for when an application requires dynamic content to be displayed; can be reused across an application, for example, for a data bound table control with dynamic rows

Design::::::::::::::::: Writing doesn't require much application designing because they are authored at design time and mostly contain static data

Writing from scratch requires a good understanding of the control's life cycle and the order in
which events execute, which is normally taken care of in user controls


REFERENCE::::: http://support.microsoft.com/kb/893667
Friend and Protected Friend Function::::::::::::::::::::::::::::::::
Friend and Protected Friend are nothing but Internal and Protected Internal in C#......., its that way in VB.NET

User Contrls vs Custom Controls:::::::::::::::::::::::::::
The main difference between the two controls lies in ease of creation vs. ease of use at design time.
Web user controls are easy to make, but they can be less convenient to use in advanced scenarios. Web user controls can be developed almost exactly the same way that you develop Web Form pages.

Like Web Forms, user controls can be created in the visual designer or they can be written with code separate from the HTML. They can also support execution events. However, since Web user controls are compiled dynamically at run time they cannot be added to the Toolbox and they are represented by a simple placeholder when added to a page.

This makes Web user controls harder to use if you are accustomed to full Visual Studio .NET
design-time support, including the Properties window and Design view previews. Also the only way to share the user control between applications is to put a separate copy in each application, which takes more maintenance if you make changes to the control.


Web custom controls are compiled code, which makes them easier to use but more difficult to create. Web custom controls must be authored in code. Once you have created the control you can add it to the Toolbox and display it in a visual designer with full Properties window support and all the other design-time features of ASP.NET server controls. In addition you can install a single copy of the Web custom control in the global assembly cache and share it between applications, which make maintenance easier
State Management in an ASP .Net application. :::::::::::::::::::::::::::

When users visit Web sites it becomes necessary to maintain session related and controls related information. In an HTTP exchange between a browser and a remote host, session related information which identifies state, such as a unique session ID, information about the user's preferences or authorisation level is preserved. Note that sessions are maintained in the data being exchanged.

State Management is the process by which we maintain session related information and additional information about the controls and its state. The necessity of state management arises when multiple users request for the same or different Web Pages of a Web Site.

State management can be accomplished using Client Side options or the Server side options.

Client Side State Management Options::::::

Client Side State Management involves storing information either on a Web page or on a Client
computer. There are four ways to manage states.


View State
Hidden Form Fields
Cookies
Query String

View State
In this method, the ViewState property that is inherited from the base Control class is used to
automatically save the values of the page and of each control prior to rendering of the page.
ViewState is implemented with a hidden form field called the _VIEWSTATE, which is automatically created in every Web Form page. When ASP.Net executes a Web page on a Web Server, the values stored in the ViewState property of the page and controls on it are collected and formatted into a single encoded string. The encoded string is then assigned to the Value attribute of the hidden form field _VIEWSTATE and is sent to the client as a part of the Web page.


Hidden Form Fields
In ASP.Net we can use the HTML standard hidden fields in a Web Form to store page-specific
information. A hidden field does not render in a Web browser. However, we can set the properties of the hidden field. When a page is submitted to the server, the content of the hidden field is sent in the HTTP Form collection along with values of other controls.


Cookies
A cookie is a small data structure used by a Web server to deliver data to a web client. A cookie
contains page specific information that a Web server sends to a client along with Page output.
Cookies are used to keep track of each individual user who accesses the web page across a HTTP connection.


Query String
The Query string is a part of the request that appears after the Question mark (?) character in the URL. A query string provides a simple way to pass information from one page to another.


Server Side State Management Options ::::::::::::::::::::

Application State
ASP.Net provides application state as a means of storing global application specific information.
The information in the application state is stored in a key value pair and is used to maintain data consistency between server round trips and between pages.

Session State
In this option session state used to store session specific information for a Web site. In session
state, the scope fo session state is limited to the current browser session. In case, many users are accessing the same Web application, each will have a different session state. If a user exits from a Web applicatin and returns later, it will be a different session state.


Database Support
Another option is the database support option. Database support is used in combination with cookies or session state. The database used is usually a relational database.

.NET 3.0:::::::::::::::::::::::::::::::::

NET Framework 3.0, formerly called WinFX, includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems. It is also available for Windows XP SP2 and Windows Server 2003 as a download. There are no major architectural changes included with this release; .NET Framework 3.0 includes version 2.0 of the Common Language Runtime.

.NET Framework 3.0 consists of four major new components:

Windows Presentation Foundation (WPF), formerly code-named Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.

Windows Communication Foundation (WCF), formerly code-named Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services.

Windows Workflow Foundation (WWF) allows for building of task automation and integrated transactions using workflows.

Windows CardSpace (WCS), formerly code-named InfoCard; a software component which securely stores a person's digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website.
Feature SQL Server 2000 SQL Server 2005:::::::::::::::::::::::::::

Server Programming Extensions Limited to extended stored procedures, which are difficult to write and can impact the server stability. The incorporation of the CLR into the relational engine allows managed code written in .NET languages to run. Different levels of security can protect the server from poorly written code.

T-SQL Error Handling Limited to checking @@error, no much flexibility. Addition of TRY/CATCH allows more mature error handling. More error_xx functions can gather additional information about errors.T-SQL Language SQL Language enhanced from previous versions providing strong data manipulation capabilities. All the power of SQL Server 2000 with the addition of CTEs for complex, recursive problems, enhanced TOP capabilities, PIVOT/APPLY/Ranking functions, and ROW_NUMBERAuditing Limited support using triggers to audit changes. Robust event handling with EVENT NOTIFICATIONS, the OUTPUT clauses, and DDL triggers.

Large Data Types Limited to 8k for normal data without moving to TEXT datatypes. TEXT is hard to work with in programming environments. Includes the new varchar(max) types that can store up to 2GB of data in a single column/row.

XML Limited to transforming relational data into XML with SELECT statements, and some simple query work with transformed documents. Native XML datatype, support for schemas and full XPATH/XQUERY querying of data.

ADO.NET v1.1 of ADO.NET included enhancements for client development. v2 has more features, including automatic failover for database mirroring, support for multiple active result sets (MARS), tracing of calls, statistics, new isolation levels and more.

Messaging: No messaging built into SQL Server. Includes Service Broker, a full-featured asynchronous messaging system that has evolved from Microsoft Message Queue (MSMQ), which is integrated into Windows.

Reporting Services An extremely powerful reporting environment, but a 1.0 product. Numerous enhancements, run-time sorting, direct printing, viewer controls and
an enhanced developer experience.

ETL DTS is a very easy to use and intuitive tool. Limited capabilities for sources and
transformations. Some constructs, such as loops, were very difficult to implement. Integration
Services is a true programming environment allowing almost any source of data to be used and many more types of transformations to occur. Very complex environment that is difficult for non-DBAs to use. Requires programming skills.


Full-Text Search Workable solution, but limited in its capabilities. Cumbersome to work with in many situations. More open architecture, allowing integration and plug-ins of third party extensions. Much more flexible in search capabilities
Session Variables are not getting captured on deployment?????????????

Add the following in the HTTP Header of the virtual directory::::::::::::::::
p3p -- Custom Header Name
CP=123 -- Custom Header Value

All abt design patterns definitions::::::::::::::::::::::::.

http://en.wikipedia.org/wiki/Design_Patterns#Creational_patterns.2C_Chapter_3
All abt mutex in .net::::::::::::::::::::

http://msdn2.microsoft.com/en-us/library/system.threading.mutex.aspx

All abt Master PAges in .net::::::::::::::::

http://www.odetocode.com/Articles/450.aspx

All abt Destructors in C# :::::::::::::::::::::

http://msdn2.microsoft.com/en-us/library/66x5fx1b(VS.80).aspx

Add new row concept:::::::::::::::::::::

http://www.eggheadcafe.com/articles/20060513.asp
Having 2 different files with 2 different languages in app_code folder:::::::::::::::::::::::::::

put all CS files in CS folder under app_code
put all VB files in VB folder under app_code
and do put the following in web.config file

<_compilation _debug="_">
<_codesubdirectories>
<_add _directoryname="_">
<_add _directoryname="_">
<_/_codesubdirectories>
<_/_compilation>
Differences bw Session and View State::::::::::::::::::::::::::::::::

Session, View State both stores state information. This is particularly of importance as HTTP is generally stateless what this effcetively means is it does not link requests from same user.

View State is
Page Specific,
control Specific,
Simple Stored in hidden field,
No Server Resource is consumed,
Good for Web Farm,
However page load will slow down, Can be tampered, Not accessible from other pages

Session is Stored in Server. (Potentially can eat up lot of resource)
Accessible from other pages

How to Register User Controls and Custom Controls in Web.config:::::::::::::::

u neednt register user controls in every page of a webapplication, instead register it in web.config as below
-------------------------------------------------------------------------------
<_system._web>
<_pages>
<_controls>
<_add _tagprefix="_" _src="_" _tagname="_header">
<_add _tagprefix="scottgf" _src="_~/_Controls/_Footer._ascx" _tagname="_footer">
<_/_controls>
<_/_pages><_/_system._web>
-------------------------------------------------------------------------------
Use this in the webpage as below
-------------------------------------------------------------------------------

<_html>
<_body>
<_form _id="_form1" _runat="_server">
<_scottgu:_header _id="_MyHeader" _runat="_server">
<_/_form>
<_/_body>
<_/_html>
-------------------------------------------------------------------------------
Reference::::: http://weblogs.asp.net/scottgu/archive/2006/11/26/tip-trick-how-to-register-user-controls-and-custom-controls-in-web-config.aspx

Top Ten New and Exciting Features in ASP.NET 2.0:::::::::::::::::

http://www.theserverside.net/tt/articles/showarticle.tss?id=WhatsNewASPNET

TO enable readonly and then read the same for a aspnet control:::::::::::::::::vvvvvvvvvimp

_txtFromDate._Attributes._Add("_ReadOnly", "_ReadOnly");
_txtToDate._Attributes._Add("_ReadOnly", "_ReadOnly");

Hence, set _readonly="_readonly", so v can even retrieve the value. If v say _readonly=_true, then it can just be viewed but never be able to get the value.


NOTE::
Cache::::::: not user specific
Session::::: user specific
Command object :::::::: used to command the database


.NEt 3.0 overview::::::::::::::::::::::::::::::::::::
http://nilangshah.wordpress.com/2007/07/10/net-framework-30-introduction-and-useful-resources/

Master page tricks and tips:::::::::::::
http://www.odetocode.com/Articles/450.aspx

NOTE:::::::::::::::::::::

Whenever master page being used along a date picker, the selected date cant be picked on to the date text box. Hence, use the following 3rd party dll which will not discriminate date picker and the text box, which on selection of a date shall automatically fetches it on the text box

Reference: http://www.codeproject.com/useritems/ASPNET_JS_Calendar.asp


Note::::::::::::::::::vvvvvvvvvvvvimp
Response.Redirect vs Server.Transfer

Response.Redirect can be used for both .aspx and html pages whereas Server.Transfer can be used only for .aspx pages.
Response.Redirect can be used to redirect a user to an external websites. Server.Transfer can be used only on sites running on the same server. You cannot use Server.Transfer to redirect the user to a page running on a different server.
Response.Redirect changes the url in the browser. So they can be bookmarked. Whereas Server.Transfer retains the original url in the browser. It just replaces the contents of the previous page with the new one.