What is use of the AutoEventWireup attribute in the Page directive ?

What is use of the AutoEventWireup attribute in the Page directive ? 


 The AutoEventWireUp is a boolean attribute that allows automatic wireup of page events when this attribute is set to true on the page. It is set to True by default for a C# web form whereas it is set as False for VB.NET forms. Pages developed with Visual Studio .NET have this attribute set to false, and page events are individually tied to handlers.

Wireup means binding the mathods with an event.Like by buttonclick event we are giving a method name so that that when ever a click event will be fired that method will be called.


When AutoEventWireUp is true we no need to specially bind the methods to the events for the page events .But When AutoEventWireUp is false we have to explicitly specify the the events for the page events.

Like When AutoEventWireUp is false we have to explicitly bind the pageload events in the pageinit event otherwise pageload event will not be fired.

What is Event Bubbling in asp.net ? 

 For every control in asp.net there are some pre defined events which could be handled for example let us take a button which has an OnClick() event when ever a single click is made to that button that event raises.

But if that particular button is in any of the following Server controls like GridView,Repeater,DataList etc .
We cannot retrieve the button onClick() event directly. For that let us consider we have the same button in GridView.

Here Button is the child control where as the parent control is our Gridview. These child controls do not raise by themselves when they are inside any server controls , they pass the event to the container parent and from then it is passed to our page as "ItemCommand". From the code behind we cann access button onclick event now with that ItemCommand Event of Parent control.

This process of sending the child control events to parent control is said to be
Event Bubbling

Explain what is Extender provider component? How to use this in the project? 


 This is a component which provides properties and features to other components or controls. This mechanism is usually used in windows forms applications. The examples of extender provider components are ToolTip, HelpProvider, and ErrorProvider etc.

How to make an ASP page to refresh after certain time ? 


Inorder to make a particular page to be refreshed after a particular time at page level of the asp page we need to specify like this :

<meta http-equiv="refresh" content="15" />

The above statement will make a particular page to be refreshed for every 15 seconds.
In real time if we see cricinfo webpage for every default period of time the page gets refreshed.

Difference between Datalist and Gridview 

Gridview support's selection, editing , sorting and paging whereas Datalist can't support sorting and paging but support selection and
editing

What is the difference between Machine.config and web.config? 

 The main difference between Machine.config and web.config is as follows:
Machine.config is machine level config file,means if you make any changes into this file, it will applicable for all application which exists on same machine.

While Web.config settings only applicable for application level.This file is best place to keep your connection string and SMTP like settings and so on.

How To Get All Session Variables And Values?

string SessionVariableName;
string SessionVariableValue;

foreach (string SessionVariable in Session.Keys)
{
SessionVariableName = SessionVariable;
SessionVariableValue = Session[SessionVariableName].ToString();

}

How To Get Current URL? 

lable1.Text=Request.Url.AbsoluteUri;

How To Detect Is Visitor Using Secure (HTTPS) Connection? 

 bool SecureConnection = Request.IsSecureConnection;

How To Close Browser Window With Button Click?

 btnClose.Attributes.Add("OnClick", "window.close();");

Do webservices support data reader?

No. However it does support a dataset
Data Reader is connected datasource, read only, forward only record set.

Dataset is disconnected datatsource resides in memory database that can store multiple tables, relations and constraints

You are working on an ASP.NET application. One of the drop down list contans 1 lakh records. The page posting becomes very slow. How to overcome this? You just need the selected index of the dropdownlist on submit.


Use EnableVieState=false. On the dropdown change event, set a hidden field value to the selected index.

Disabling view state helps us in reducing the postback load.

Which is the method to register javascript in ASP.NET?


Client.RegisterStartupScript()

Eg: ClientScript.RegisterStartupScript(GetType(), "key", "script");

Can we add multiple script managers on a single page?

No it will throw error, a page can contain only one ScriptManager control in its hierarchy. To register services and scripts for nested pages, user controls, or components when the parent page already has a ScriptManager control, use the ScriptManagerProxy control.

The purpose of ScriptManager is just to enables AJAX In Your Web Application. so adding multiple ScriptManager doesn't make any sense.

What are the advantages and disadvantages of viewstate?

The primary advantages of the ViewState feature in ASP.NET are:
1. Simplicity. There is no need to write possibly complex code to store form data between page submissions.
2. Flexibility. It is possible to enable, configure, and disable ViewState on a control-by-control basis, choosing to persist the values of some fields but not others.
There are, however a few disadvantages that are worth pointing out:
1. Does not track across pages. ViewState information does not automatically transfer from page to page. With the session
approach, values can be stored in the session and accessed from other pages. This is not possible with ViewState, so storing
data into the session must be done explicitly.
2. ViewState is not suitable for transferring data for back-end systems. That is, data still has to be transferred to the back
end using some form of data object

What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?

Server.Transfer() : client is shown as it is on the requesting page only, but the all the content is of the requested page. Data can be persist accros the pages using Context.Item collection, which is one of the best way to transfer data from one page to another keeping the page state alive.
Response.Dedirect() :client know the physical location (page name and query string as well). Context.Items loses the persisitance when nevigate to destination page. In earlier versions of IIS, if we wanted to send a user to a new Web page, the only option we had was Response.Redirect. While this method does accomplish our goal, it has several important drawbacks.
The biggest problem is that this method causes each page to be treated as a separate transaction. Besides making it difficult to maintain your transactional integrity,
Response.Redirect introduces some additional headaches.
First, it prevents good encapsulation of code.
Second, you lose access to all of the properties in the Request object. Sure, there are workarounds, but they're difficult.
Finally,Response.Redirect necessitates a round trip to the client, which, on high-volume sites, causes scalability problems. As you might suspect, Server.Transfer fixes all of these problems. It does this by performing the transfer on the server without requiring a roundtrip to the client.

How can we call javascript function in page load event?

this.button.Attributes.Add("OnClick",return functionname(););

Where Session is Stored in ASP.NET?

There are three locations where a session can be stored :

1)InProc : If you set this mode, then session is stored in Web Server worker process(aspnet_wp.exe). This is by default and the performance is fast because it resides in the same worker process.

2)StateServer : If you set this mode, then session is stored in a separate process in the server called aspnet_state.exe.

3) SqlServer : If you set this mode, then session is Stored in SQL Server.

What are all the various authentications in Asp.Net?

 Selecting an authentication provider is as simple as making an entry in the web.config file
for the application. You can use one of these entries to select the corresponding built in
authentication provider:
1. &lt;authentication mode="windows">
2. &lt;authentication mode="passport">
3. &lt;authentication mode="forms">
4. Custom authentication where you might install an ISAPI filter in IIS that
compares incoming requests to list of source IP addresses, and considers
requests to be authenticated if they come from an acceptable address. In that
case, you would set the authentication mode to none to prevent any of the
.net authentication providers from being triggered.

1. Windows authentication and IIS
If you select windows authentication for your ASP.NET application, you also have to
configure authentication within IIS. This is because IIS provides Windows authentication.
IIS gives you a choice for four different authentication methods:
Anonymous,basic,digest and windows integrated
If you select anonymous authentication, IIS doesn't perform any authentication, Any one
is allowed to access the ASP.NET application.
If you select basic authentication, users must provide a windows username and password
to connect. How ever this information is sent over the network in clear text, which makes
basic authentication very much insecure over the internet.
If you select digest authentication, users must still provide a windows user name and
password to connect. However the password is hashed before it is sent across the network.
Digest authentication requires that all users be running Internet Explorer 5 or later and
that windows accounts to stored in active directory.
If you select windows integrated authentication, passwords never cross the network.
Users must still have a username and password, but the application uses either the Kerberos
or challenge/response protocols authenticate the user. Windows-integrated authentication
requires that all users be running internet explorer 3.01 or later Kerberos is a network
authentication protocol. It is designed to provide strong authentication for client/server
applications by using secret-key cryptography. Kerberos is a solution to network security
problems. It provides the tools of authentication and strong cryptography over the network
to help to secure information in systems across entire enterprise

2. Passport authentication
Passport authentication lets you to use Microsoft's passport service to authenticate users
of your application. If your users have signed up with passport, and you configure the
authentication mode of the application to the passport authentication, all authentication
duties are off-loaded to the passport servers.
Passport uses an encrypted cookie mechanism to indicate authenticated users. If users
have already signed into passport when they visit your site, they'll be considered
authenticated by ASP.NET. Otherwise they'll be redirected to the passport servers to log
in. When they are successfully log in, they'll be redirected back to your site
To use passport authentication you have to download the Passport Software Development
Kit (SDK) and install it on your server. The SDK can be found at http://
msdn.microsoft.com/library/default.asp?url=/downloads/list/websrvpass.aps. It includes
full details of implementing passport authentication in your own applications.

3. Forms authentication
Forms authentication provides you with a way to handle authentication using your own
custom logic with in an ASP.NET application. The following applies if you choose forms
authentication.
a. When a user requests a page for the application, ASP.NET checks for the
presence of a special session cookie. If the cookie is present, ASP.NET assumes
the user is authenticated and processes the request.
b. If the cookie isn't present, ASP.NET redirects the user to a web form you
provide

You can carry out whatever authentication, it check's you like it checks your form. When
the user is authenticated, you indicate this to ASP.NET by setting a property, which
creates the special cookie to handle subsequent requests.

Explain how the Asp.Net Authentication process work?

ASP.NET does not run by itself, it runs inside the process of IIS. So there are two
authentication layers which exist in ASP.NET system. First authentication happens at
the IIS level and then at the ASP.NET level depending on the WEB.CONFIG file.
Below is how the whole process works:

1. IIS first checks to make sure the incoming request comes from an IP address
that is allowed access to the domain. If not it denies the request.

2. Next IIS performs its own user authentication if it is configured to do so. By
default IIS allows anonymous access, so requests are automatically
authenticated, but you can change this default on a per - application basis
with in IIS.

3. If the request is passed to ASP.net with an authenticated user, ASP.net checks
to see whether impersonation is enabled. If impersonation is enabled, ASP.net
acts as though it were the authenticated user. If not ASP.net acts with its own
configured account.

4. Finally the identity from step 3 is used to request resources from the operating
system. If ASP.net authentication can obtain all the necessary resources it
grants the users request otherwise it is denied. Resources can include much
more than just the ASP.net page itself you can also use .Net's code access
security features to extend this authorization step to disk files, Registry keys
and other resources.

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

There are six main types of validation controls :-

RequiredFieldValidator
It checks whether the control have any value. It's used when you want the control should
not be empty.

RangeValidator
It checks if the value in validated control is in that specific range. Example
TxtCustomerCode should not be more than eight length.

CompareValidator
It checks that the value in controls should match some specific value. Example Textbox
TxtPie should be equal to 3.14.

RegularExpressionValidator
When we want the control value should match with a specific regular expression.

CustomValidator
It is used to define UserDefined validation.

ValidationSummary
It displays summary of all current validation errors.
Note:- It's rare that some one will ask step by step all the validation controls. Rather they
will ask for what type of validation which validator will be used. Example in one of the
interviews i was asked how you display summary of all errors in the validation
control...just uttered one word Validation summary.

What are the requirements to run ASP.NET AJAX applications on a server?

You would need to install 'ASP.NET AJAX Extensions' on your server. If you are using the ASP.NET AJAX Control toolkit, then you would also need to add the AjaxControlToolkit.dll in the /Bin folder.


Difference between Server-Side AJAX framework and Client-side AJAX framework?

 ASP.NET AJAX contains both a server-side Ajax framework and a client-side Ajax framework. The server-side framework provides developers with an easy way to implement Ajax functionality, without having to possess much knowledge of JavaScript. The framework includes server controls and components and the drag and drop functionality. This framework is usually preferred when you need to quickly ajaxify an asp.net application. The disadvantage is that you still need a round trip to the server to perform a client-side action.
The Client-Side Framework allows you to build web applications with rich user-interactivity as that of a desktop application. It contains a set of JavaScript libraries, which is independent from ASP.NET. The library is getting rich in functionality with every new build released.


 User controls are easier to create in comparison to custom controls, however user controls can be less convenient to use in advanced scenarios.
User controls have limited support for consumers who use a visual design tool whereas custom controls have full visual design tool support for consumers.
A separate copy of the user control is required in each application that uses it whereas only a single copy of the custom control is required, in the global assembly cache, which makes maintenance easier.
A user control cannot be added to the Toolbox in Visual Studio whereas custom controls can be added to the Toolbox in Visual Studio.
User controls are good for static layout whereas custom controls are good for dynamic layout.

Can you nest UpdatePanel within each other?

Yes, you can do that. You would want to nest update panels to basically have more control over the Page Refresh.

Explain the UpdatePanel?

The UpdatePanel enables you to add AJAX functionality to existing ASP.NET applications. It can be used to update content in a page by using Partial-page rendering. By using Partial-page rendering, you can refresh only a selected part of the page instead of refreshing the whole page with a postback.

Can we use multiple ScriptManager on a page?

No. You can use only one ScriptManager on a page.

What is a nested master page? How do you create them?

A Nested master page is a master page associated with another master page. To create a nested master page, set the MasterPageFile attribute of the @Master directive to the name of the .master file of the base master page.

How can you sort the elements of the Array in descending order?

 We can sort the array in descending order by calling
Array.Sort() and then by calling Array.Reverse() method.

Can we have more than 1 web.config file?

Yes we can have more than 1 web.config but in different folder.
In root we can have only 1 web.config file

If there is a button on asp page what is the order of event when button is Clicked?Page_Load or Button_Click?

Page_Load() would fire first than Button_Click

What are Events fired for User Control in ASP.NET ?

 The Sequence of User controls Execution as follows.

OnInit of the user control
OnInit of the containing page
OnLoad of the containing page
OnLoad of the user control

How to create an instance of a user control programmatically in the code behind file of a Web Forms page

Create a new Web Forms page in Visual Studio.
Navigate to the code behind file generated for this Web Forms page.
In the Page_Load event of the Page class, write the following code.
// Load the control by calling LoadControl on the page class.
Control c1 = LoadControl("test.ascx");

// Add the loaded control in the page controls collection.
Page.Controls.Add(c1);

How to use a user control in a Web Forms page

Declare the @ Register directive.

For example, use the following code.
<%@ Register TagPrefix="UC" TagName="TestControl" Src="test.ascx" %>

Differences between Array And array list?

Array:
--------------------------------------------------------------
1)It is used when same datatypes r having
2)I's mainly for static list
3)Array can accesses by using Indexes


Array List:
--------------------------------------------------------------
1)It is used when poly datatypes r having
2)I's mainly for dynamic list
3)Array can accesses by using keys

Suppose if u have Two Web config files one is External And one more webconfig in folder? Which WebConfig file executed first?

External WebConfig is executed first...........

what is Delegate?

When a class contains 10 methods and need to access those methods then we normally access these objects through obj.methodname() one by one.
But with the help of the delegate we can access all 10 methods a single time with the help of the delegate.

i)Delegate is a function pointer.
ii) It allows the programmer to encapsulate a reference to a method inside a delegate object.
iii) Delegates are type-safe(type-safe function pointer which means that the parameter list and the return type are known. ) and secure.
iv) Delegates are created at run time
v)Delegates allow methods to be passed as parameters.
Vi)Delegates can be chained together; for example, multiple methods can be called on a single event.
Vii)Delegates can be used to define callback methods.
viii)"Delegates are ideally suited for use as events "

About UPDATE PANEL?

Partial Upadate of a web page ,Like what ever the controls we place in update panel those will be be loaded
on every action update panel control.
Those controls which are placed outside the update panel are loaded on page submission to server.

Response.Redirect vs server.transfer

Response.Redirect sends message to the browser saying it to move to some different page.
While server.transfer does not send any message to the browser but rather redirects the user
directly from the server itself. So in server.transfer there is no round trip while response.
redirect has a round trip and hence puts a load on server.

About cookies?

20 cookies per domain
->Max 300 cookies can be stored on the user's system
->Max Cookies Size 4 kilobytes

How to get values across multiple pages using ViewState?

Ans. In page1.aspx

button_1click envent
{
ViewState["name"] = txtTest.Text;
Server.Transfer("page2.aspx");

}

In page2.aspx
In page_load
{

Page obj= this.PreviousPage;
TextBox txtNewTest = (TextBox)obj.FindControl("txtTest");
string sDisplay = txtNewTest.Text.ToString();
Response.Write(sDisplay);

}

what is Stack and Heap? 

stack is used to store variable data of fixed length.
stack is LIFO ie one the last item in stack is first served and also removed first.


Heap is used to store data whose size and length can only be determined at runtime and are subjected to change.
But a reference to that data is stored on the stack.

so anything in our Heap can be accessed at any time.

What is Managed and UnManaged code/


Managed Code:

The code, which is developed in .NET framework, is known as managed code. This code is directly executed by
CLR with help of managed code execution. Any language that is written in .NET Framework is managed code.

Managed code uses CLR which in turns looks after your applications by managing memory, handling security,
allowing cross - language debugging, and so on.



Unmanaged Code

The code, which is developed outside .NET, Framework is known as unmanaged code.

Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages
such as C++ can be used to write such applications, which, for example, access low - level functions of
the operating system. Background compatibility with code of VB, ASP and COM are examples of unmanaged code.

Unmanaged code can be unmanaged source code and unmanaged compile code.

Unmanaged code is executed with help of wrapper classes.

Wrapper classes are of two types: CCW (COM Callable Wrapper) and RCW (Runtime Callable Wrapper).

Wrapper is used to cover difference with the help of CCW and RCW.

What methods are fired during the page load?

Init() - when the pageis 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.

DataSet Contains 100 Rows
How to Select 50 Rows in DataSet

ds.Tables[0].rows.select(50).Tostring();

how to pass the values across webforms without using State Management Concepts:

Page1.aspx.cs

public String CurrentCity
{
get
{
return TextBox1.Text;
}
}


In Page2.aspx

<%@ PreviousPageType VirtualPath="~/Page1.aspx" %>

Label1.Text=PreviousPage.CurrentCity;

Another Method:

In Page2.aspx

TextBox SourceTextBox = (TextBox)PreviousPage.FindControl("TextBox1");

Label1.Text = SourceTextBox.Text;

what is Replication?

Replication is a set of technologies for copying and distributing data and database objects from one database to another
and then synchronizing between databases to maintain consistency.
Using replication, you can distribute data to different locations and to remote or mobile users over local and wide area
networks, dial-up connections, wireless connections, and the Internet.

What Is a Satellite Assembly?

.NET Framework assembly containing resources specific to a given language. Using satellite assemblies, you can place the
resources for different languages in different assemblies, and the correct assembly is loaded into memory only if the user
elects to view the application in that language."

what is Impersonation?

Another important security feature is the ability to control the identity under which code is executed.
Impersonation is when ASP.NET executes code in the context of an authenticated and authorized client.
By default, ASP.NET does not use impersonation and instead executes all code using the same user account as the ASP.NET process, which is typically the ASPNET account.
This is contrary to the default behavior of ASP, which uses impersonation by default. In Internet Information Services (IIS) 6, the default identity is the NetworkService account.

What are the two classes r used to send mail in Asp.net?

1)Mail Message
2)SMTP

Which protocol is used to Communicate with the webservice?

SOAP(Simple Object Access Protocol)

What is Forms Authentication?

Forms authentication uses an authentication ticket that is created when a user logs on to a site, and then it tracks the user throughout the site. The forms authentication ticket is usually contained inside a cookie.

What is the use of Server.Transfer() method?

Server.Transfer() is a member of HttpServerUtility Class that contains helper methods for processing web queries/requests. When we use Transfer() the current page will terminate and a new page will be processed instated of the old page. This processing takes place in the server and the browser will not be updated to show the new URL.

IIS ISOLATION LEVELS

IIS has three level of isolation:-

1.LOW (IIS process):- In this main IIS process and ASP.NET application run in same process.
So if any one crashes the other is also affected.
Example:
I have hosted yahoo , hotmail .amazon and google on a single PC. So all application and the IIS process runs on the same process.In case any website crashes it affects every one.

2.Medium (Pooled):- In Medium pooled scenario the IIS and web application run in different process. So in this case there are two processes process1 and process2.In process1 the IIS
process is running and in process2 we have all Web application running.

3.High (Isolated):-In high isolated scenario every process is running is there own process.but consumes heavy memory but has highest reliability.

difference between URI AND URL

A Uniform Resource Identifier(URI) is a string of characters
which identifies an Internet Resource.

The most common URI is the Uniform Resource Locator (URL) which identifies an Internet domain address.

difference between web farm and web garden

webfarm is a multiple server scenario whereas webgarden is a multiple process scenario.
in webfarm we have server in each and every place.if one crashes or load excessively the other burnt or fails.so there arise a situation to load the balance between the multiple servers.
various modes of bearing the balance are:

A)ROUND ROBIN(ALL SERVERS LOAD BALANCE EQUALLY)
B)NLB
C)HLB
D)HYBRID

Which method is used to force all the validation controls to run ?

 Page.Validate()

What are major built in Objects in asp.net ? 

Application

Request

Response

Server

Session

Context

Trace

What is the Limitation for Application State?

1)Application Object Stores State of a User In Website Itself.
2)Which Leads to Burden To The Web Application and reduces the performance
3)The Scope of Web Application holds Until Website restarts?

What is Application State?

Application State is one of the Server Side State management Mechanism which stores application memory on the server rather than persisting data in the client side memory.

What is XPath?

Xpath is a query language for selecting nodes from an XML document.

What are the different sessionStates in ASP.NET?

1)InProc
2)StateServer
3)SqlServer
4)Custom
5)Off

Is It Possible To Overload Web Method?

Yes we Can Add Overload Webmethods By Using MessageName

[WebMethod]
public int Addition(int i, int j)
{
return i + j;
}
[WebMethod(MessageName="Add2")]
public int Addition(int i, int j, int k)
{
return i + j + k;
}
}

what is difference between inprocess and outprocess session?

Inprocess session will be created within appdomain.
Outprocess session will be created outside the worker process.

what is session ,cache, cookie, application memory timeout?


Session timeout: 20 min
Cache timeout: duration we have to specify.
Cookie: for in memory cookie till browser opened
For persistent cookie timeout is till expires property's time .
Application memory timeout: till appdomain exist

What is the difference between Application caching and session objects?

Session A session is the time for which a particular user interacts with a web application. During a session the unique identity of the user is maintained internally. A session ends if there is a session timeout or user ends sessionby logging out.Sessions may change from user to user.

Cache Caching can be used to temporarily store page output or application data either on the client or on the server, which can then be re-used to satisfy subsequent requests and thus avoid the overhead of re-creating the same information.Caching is particularly suitable when you expect to Cache will be applicable to the entire application through out it's life cycle return the same information in the same format for many different requests.

Application Its nothing but similar to Session with a bit difference that is Session objects have scope within a particular session while application objects having scope within entire application. Application are accessible only from code running within the context of the originating application. Other applications running on the system cannot access or modify the values.

can asp.net website runs without web.config file?

Yes, and it will take the default setting from machine.config file from the machine. so web.config file is not necessary or must for running or publishing website or web application.

What is Cross-Page Posting?

Whenever you send a request to the server it sends request to the same page. Cross_page posting means it will send request to the another page. we can achieve. this through postback url property

What's the maximum size of a view state?

Maximum size of a viewstate should not be more than 25-30% of the page size

What is the use of SavePageStateToPersistenceMedium ?

 It's a Page class method allows developers to store ASP.NET Page Viewstate on server side instead of storing in client side hidden control

Is there any limit of cookies can be used in a website. If yes, how many?

 Yes. It's there. we can have upto 20 cookies per website.

What is Fragmant caching in Asp.Net?

 Fragment caching refers to the caching of individual user controls within a Web Form.


How do we Refresh Parent Page From Child Popup Page?

 Using the code
window.opener.parent.location.href="Parent.aspx";

What is the root class in dot net?

 System.object

is the root class in Dot net.

How to use favicon in asp.net site ?

 <link rel="shortcut icon" href="favicon.ico" />
simply paste this line before the head tag endings
here fivicon.ico should be added in your solution explorer root folder

How to Kill the cookies in a page?

To kill the cookies in a page use
Cookies.Discard()

What data type does the RangeValidator control support in Asp.net?

 There are 3 Data type RangeValidator control support

1)Integer
2)String
3)Date

How ASP .NET different from ASP?

In ASP.NET Scripting is separated from the HTML, Code is compiled as a DLL,
these DLLs can be executed on the server.

what are the differences between Datalist DataGrid and datarepeater ?

DataList
*Has table appearence by default
*Has no autoformat option
*has no default paging & sorting options
*can define separators between elements using template
DataGrid
*Has a grid appearence by default
*has a autoformat option
*has default paging and sorting
*has no separator between elements
DataRepeater
simple,read-only output, has no built in support for selecting or editing items, has no DEFAULT APPEARENCE,
has no default paging.

How do you create a permanent cookie?

 By setting the time out as infinite

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

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 does the "EnableViewState" property do? Why would I want it on or off?

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.

What is the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it's being operated on, a new instance is created.

What is the difference between Session.Abandon() and Session.Clear()?

Session.Abandon() will end current session by firing Session_End and in the next request, Session_Start will be fire.

Session.Clear( ) just clears the session data without killing it. With session.clear variable is not removed from memory it just like giving value null to this session.

Session ID will remain same in both cases, as long as the browser is not closed.

How to start NotePad file in AsP.NET with code ?

System.Diagnostics.Process.Start("Notepad.exe");

ASP.Net pages are compiled and are not interpreted. True or False.

True

How ASP .NET different from ASP?

In ASP.NET Scripting is separated from the HTML, Code is compiled as a DLL,
these DLLs can be executed on the server.

what are the differences between Datalist DataGrid and datarepeater ?

DataList
*Has table appearence by default
*Has no autoformat option
*has no default paging & sorting options
*can define separators between elements using template
DataGrid
*Has a grid appearence by default
*has a autoformat option
*has default paging and sorting
*has no separator between elements
DataRepeater
simple,read-only output, has no built in support for selecting or editing items, has no DEFAULT APPEARENCE,
has no default paging.

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

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.

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

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 is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?

Server.Transfer() : client is shown as it is on the requesting page only, but the all the content is of the requested page. Data can be persist accros the pages using Context.Item collection, which is one of the best way to transfer data from one page to another keeping the page state alive. Response.Dedirect() :client know the physical loation (page name and query string as well). Context.Items loses the persisitance when nevigate to
In Response redirect The user's browser history list is updated to reflect the new address.

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

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.

What is the advantage of using System.Text.StringBuilder over System.String?

StringBuilder is more efficient in the cases, where a lot of manipulation is done to the text. Strings are immutable, so each time it's being operated on, a new instance is created.

What is the difference between Session.Abandon() and Session.Clear()?

Session.Abandon() will end current session by firing Session_End and in the next request, Session_Start will be fire.

Session.Clear( ) just clears the session data without killing it. With session.clear variable is not removed from memory it just like giving value null to this session.

Session ID will remain same in both cases, as long as the browser is not closed.

What method must be overridden in a custom control ?

The Render() method

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).

Client Sertificate is a collection of ___________ ? (Request / Response / Server)

Request

What is the size of the session ID ?

 32 bit long integer

What Type of Processing model asp.net simulates ?

 Event-driven

Which class can be used to perform data type conversion between .NET data types and XML types?

 XmlConvert

What is the maximum number of cookies that can be allowed to a web site

 20 cookies

What does WSDL stand for?

 Web Services Description Language.
 

can we use session variable in App_code Class page ?

 Yes.
By using "HttpContext.Current.Session("VarName") ", we can use current session variable in App_code Class page

How does ASP.NET store SessionIDs by default?

In cookies

The DateTime type is a non-nullable value type, and just like an integer, it cannot be assigned to null.

How many ViewState objects can be created on an aspx page ?

 There is no limit. You can have any number of ViewState object on single aspx page. However more Viewstate objects, more slowly it loads.

what is the meaning of immutable?

 immutable means we can not change the contents at run time,
example of immutable is String

If cookies is disabled in client browser will session work ?

 If cookieless is true it will work. If it is not, it won't work.

Whether Http maintain states by default?

 No. Http is a stateless protocol. Inorder to maintain the state we need either of the following in the pages.

View state
Session
Cookies
Cache
Query string or Request.Form

How do you hide the columns of a gridview?

 By setting a column's Visible property of a column as false or by the style display:none property.
 

Suppose you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler?

 Add an OnMouseOver attribute to the button. Example: btnSubmit.Attributes.Add("onmouseover","someClientCodeHere();");
 

What's the difference between Response.Write() andResponse.Output.Write()?

 Response.Output.Write() allows you to write formatted output but Response.Write doesnt allow.

Example:Response.Output.Write("{0:d}", "Current Date Time: ", DateTime.Now)

In how many ways you can deploy an Asp.Net Application?

1)XCopy deployment->only copy the whole application into the webserver
2)PreCompiled deployment->1st the application willl be compiled and then copy into the web server.
3)SetUp Program deployment

Can two different programming languages be mixed in a single ASPX file?

 ASP.NET's built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.
 

What is the difference between Server.Transfer and Response.Redirect?

 * Response. Redirect: This tells the browser that the requested page can be found at a new location. The browser then initiates another request to the new page loading its contents in the browser. This results in two requests by the browser.
* Server. Transfer: It transfers execution from the first page to the second page on the server. As far as the browser client is concerned, it made one request and the initial page is the one responding with content. The benefit of this approach is one less round trip to the server from the client browser. Also, any posted form variables and query string parameters are available to the second page as well.

Enumerate the types of Directives.

@ Page directive
@ Import directive
@ Implements directive
@ Register directive
@ Assembly directive
@ OutputCache directive
@ Reference directive

What is Shadow Copy?

In order to replace a COM component on a live web server, it was necessary to stop the entire website, copy the new files and then restart the website. This is not feasible for the web servers that need to be always running. .NET components are different. They can be overwritten at any time using a mechanism called Shadow Copy. It prevents the Portable Executable (PE) files like DLLs and EXEs from being locked. Whenever new versions of the PEs are released, they are automatically detected by the CLR and the changed components will be automatically loaded. They will be used to process all new requests not currently executing, while the older version still runs the currently executing requests. By bleeding out the older version, the update is completed.

Which protocol for defining the format of an Email message?

MIME

Difference between Eval() and Bind()?

Eval():-
Eval() method proviedes only for displaying data from a datasource in a control.
Bind():-
Bind() methods provides for two-way binding which means that it cannot be used to dispaly as well update data from a datasource

What is persistent and non-persistent cookie?

Persistent Cookies : This can be said as permanent cookies, which gets stored on user's machine. For persistent cookie, one need to set the expiry date.

Non Persistent Cookies : This is Temporary Cookies which get's stored in browser's memory.

Is it possible to use InProc mode for sessionState in case of web garden?

No, it's not possible. As InProc mode is dependent on the worker process and in case of web garden, we have multiple worker process so session handling becomes difficult. Either we can use StateServer or SQL server mode for web garden.

Is it possible to set SessionState to readonly mode? Readonly mode means, we can only read data from session but we can not write any data in session variable?

Yes, it is possible.
EnableSessionState property has a value "Readonly" which actually makes the session state read only.

What is the difference between Session.Clear() and Session.RemoveAll() method?

Well, actually there is no difference. Session.RemoveAll() methods internally makes a call to Clear() method only.

What is Cookie Munging?

By default, asp.net uses cookies to store session id for the logged in user. But there is an option in every browser to disable cookies. If cookies are disabled, then any website will not be able to create cookies on user's machine.

When cookies are disabled, then session Id is gets appended in the URL and passed to the server. Server decodes it and fulfill the requested page.

Cookie Munging is nothing but how ASP.NET manages session variables without cookies.

Explain differences between the page execution lifecycle of an ASP.NET page and an ASP.NET AJAX page?

In an asynchronous model, all the server side events occur, as they do in a synchronous model. The Microsoft AJAX Library also raises client side events. However when the page is rendered, asynchronous postback renders only the contents of the update panel, where as in a synchronous postback, the entire page is recreated and sent back to the browser.

Difference between Server-Side AJAX framework and Client-side AJAX framework?

ASP.NET AJAX contains both a server-side Ajax framework and a client-side Ajax framework. The server-side framework provides developers with an easy way to implement Ajax functionality, without having to possess much knowledge of JavaScript. The framework includes server controls and components and the drag and drop functionality. This framework is usually preferred when you need to quickly ajaxify an asp.net application. The disadvantage is that you still need a round trip to the server to perform a client-side action.
The Client-Side Framework allows you to build web applications with rich user-interactivity as that of a desktop application. It contains a set of JavaScript libraries, which is independent from ASP.NET. The library is getting rich in functionality with every new build released.

What is Ajax? What is ASP.NET AJAX?

What is Ajax?

The term Ajax was coined by Jesse James Garrett and is a short form for "Asynchronous Javascript and XML". Ajax represents a set of commonly used techniques, like HTML/XHTML, CSS, Document Object Model(DOM), XML/XSLT, Javascript and the XMLHttpRequest object, to create RIA's (Rich Internet Applications).
Ajax gives the user, the ability to dynamically and asynchronously interact with a web server, without using a plug-in or without compromising on the user's ability to interact with the page. This is possible due to an object found in browsers called the XMLHttpRequest object.

What is ASP.NET AJAX?

'ASP.NET AJAX' is a terminology coined by Microsoft for 'their' implementation of AJAX, which is a set of extensions to ASP.NET. These components allow you to build rich AJAX enabled web applications, which consists of both server side and client side libraries.
Which is the current version of ASP.NET AJAX Control Toolkit?
As of this writing, the toolkit version is Version 1.0.20229 (if you (if you are targeting Framework 2.0, ASP.NET AJAX 1.0 and Visual Studio 2005) and Version 3.0.20229 (if targeting .NET Framework 3.5 and Visual Studio 2008).

What is a web garden?

By default an application pool runs with a single worker process (w3wp.exe). We can allocate multiple worker process in a single application pool. An application which can have multiple W3WP process, is known as web Garden.

Where is Cache data stored-in memory, on the hard disk, in a database, or on a state server?

The Cache object is stored in memory.

Which property needs to be set for script manager control to extend the time before throwing time out expection if no response is received from the server?

AsyncPostBackTimeout Property needs to set which gets or sets a value that indicates the time, in seconds, before asynchronous postback time out if no response is received from the server.

<asp:scriptmanager id="scriptManager1" runat="server" asyncpostbackerrormessage="We can not serve your request at this moment.Please try later." asyncpostbacktimeout="36000"></asp:scriptmanager>


The default value of this property is 90 second. We can also set the user defined error message using asyncpostbackerrormessage property (as shown in above code) for time out.

What is the main disadvantage of using IIS to host a service?

Using IIS to host your services means that you will not be able to support non-HTTP protocols such as TCP, named pipes, and MSMQ. You will have access to the many built-in features available with IIS such as process recycling and messagebased
activation.

If a users has disabled cookies in his browsers, what can be done to enable forms authentication?

Use the AutoDetect setting.

What can you do to make a Web page more useful to a user who does not use a mouse?

 There are number of things which can be done so that Site can be accessed without a mouse.

1.Provided access keys for all the controls.You can use access keys for Web controls using AccessKey property.
2. Define Logical Tab order.
3. Specify default button on the form.
4. Set default focus on the form in a logical location where data entry normally begins.


Does ViewState is responsible for maintaining data across the Page Post Back for Postback controls (like textbox, dropdownlist) and non-postbackcontrols(like label)?

 It is false. For NonPostback controls it is true but for postback controls, ASP.NET retrieves their values one by one from the HTTP request and copies them to the control values while creating the HTTP response.

 what is difference between viewstate data and postbackdata


ViewState data is data that ASP.NET encoded end sent to the client in the _ViewState hidden field. It's basically the page as it was when it was sent to the client.
PostBack data is data that the user submits.
For example suppose you have a have a textbox on a page defined like so:
<asp:TextBox id="TextBox1" runat="server" text="Some Text" />
You type in My user input into the textbox and submit the form. Some Text would be ViewState data and My user input would be the PostBack data.

The viewstate was the current state when the page was rendered to the browser.
The post back data is what the user changed and resubmitted.

 viewstate is when the page is first displayed in the browser (page load) Post back data is when the user has made changes and submitted the form;
 view state means storing the contents of fields temporarorily where as postback means submitting the form itself .cross postback is the redirecting from one form to another form.
 http://msdn.microsoft.com/en-us/library/ms972976.aspx
 

For a blank ASP.NET Page or ViewState Disabled page, will there be any value stored in the _VIEWSTATE field? Note : The Viewstate of an ASP.NET page is created during the page life cycle, and saved into the rendered HTML using in the "__VIEWSTATE" hidden HTML field.

 Answer is YES.

The reason is that ASP.NET Page itself stores some bytes of information into the _VIEWSTATE field.

What is the difference between ListBox (Filled with data) and DropDownList (Filled with data), in terms of SelectedIndex property?

 The default value of the SelectedIndex property of the Listbox is -1, which indicates that no item is selected in the Listbox. However, the DropDownList control overrides this property and sets the default value to 0, which indicates the first item in the list.

When file upload control is used, you can add maximum 4 mb size of the file. Using which property one can extend the limit of file size?

 ValidateRequest Property needs to be set to false. By default it's true so it does not allow unencoded HTML tags to be processed at server. It can be set at page level or at application level via web.config.

Is it possible to update a connection string stored in the Web.config file programatically? If Yes, then how?

 Yes.

Create a Configuration object. Then, update the connection string using the ConnectionStrings collection. Finally, call Configuration.Save.

Which method would you call to send an e-mail message and wait for the transmission to complete before proceeding?

Select from following answers:

1.MailMessage.Send
2.SmtpClient.Send
3.SmtpClient.SendAsync
4.MailMessage.SendAsync

Correct Answer is:

SmtpClient.Send

What is the name of the Web page property that you can query to determine that a Web page is being requested without data being submitted?

IsPostBack.

Which might not work if a user has disabled cookies in his or her Web browser: application state or session state?

Session state, by default, won't work if a Web browser that supports cookies has cookies disabled. Application state isn't user-specific, though, and doesn't need to be tracked in cookies. Therefore, application state works regardless of cookies

What is a worker process?

"The "Process" which is responsible for processing Asp.net application request and sending back response to the client , is known as "Worker Process". All ASP.NET functionalities runs within the scope of this process."

"Process which is responsible for all asp.net requests and response cycle is known as worker process."

Is view state lost if a user refreshes a Web page? What if the user copies the URL and open it in other browser?

View state is maintained within a page's HTML, so it is lost if a page is refreshed or if the URL is copied.

What is View State Chunking?


View state chunking is new in ASP.NET, version 2.0.The ViewState property retains values between multiple requests for the same page. When an ASP.NET page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field. If the data is too long for a single field (as specified in the MaxPageStateField-Length property), then ASP.NET performs view state chunking to split it across multiple hidden fields.

Can we set priority (High, Medium, Low) of the mail sent via ASP.NET?

Yes..

What is the difference between Session.Abandon() and Session.Clear()?

The major practical difference is that if you call Session.Abandon(), Session_End will be fired (for InProc mode), and in the next request, Session_Start will be fired. Session.Clear( ) just clears the session data without killing it.

Ragards
Santosh
http://santoshdotnetarena.blogspot.com/


22 GridView Tips and Tricks by Sheo Narayan


In this article, we have consolidated all the GridView related articles covering many concepts which would serve as one stop reference.

Introduction of GridView

One can't imagine any .NET web application without GRIDVIEW. Undoubtedly it is most widely used
control from .NET framework. Even after its widespread acceptance, this is a control which programmer
find it little difficult to play with and achieve their specific needs.The reasons could be the complexity
and sheer span of funtionalities it offeres. Apart from displaying the data, it enables to manipulate data, present data as per need, sorting and pagination & worth to mention the customization.This is a true successor of the datagrid which belonged to earlier frameworks.

Get 500+ ASP.NET web development Tips & Tricks and ASP.NET Online training.

In this post, I am going to enlist my GridView related articles for quick reference. Do not forget to bookmark this post to help you find ready-made solutions to the GridView related issues /challenges you face in day to day life as an ASP.NET developer.1. How to populate GridView from code behind?
In this article, we shall learn how to populate GridView from the code behind using a data source.
2. How to sort the GridView data?
In this article, we shall see how to sort the GridView data.
3. How to do pagination for the GridView data?
In this article, we are going to learn how to do paginations to display large number of records on the page using GridView.
4. How to write message when there is no data to display in GridView?
In this article, we shall learn how to display a custom message when no records to display in the GridView.
5. How to select a GridView row and persist the selected record in the GridView?
In this article, we shall learn how to select GridView record and persisit the selection across different pages of the GridView.
6. How to select multiple records from GridView and retrieve selected records value?
In this article we are going to learn how to select multiple records from the GridView and retrieve selected records, we can follow this approach.
7. How to select multiple records from the GridView and persist the selection during pagination?
In this article, we shall see how to select multiple records from the GridView and persist the selection across different pages.
8. How to select all records (checkboxes for each record)?
In this article, we shall learn how to select all records from the GridView using CheckBox.
9. How to generate edit, delete, update and select buttons automatically?
In this article, we shall learn how to generate Edit, Delete, Update and Select buttons automatically in the GridView.
10. How to perform (CRUD) Edit, Update, and Delete operation in GridView?
In this article, we shall learn how to perform CRUD operation (create, read, update and delete) operation in GridView.
11. How to add a button with custom command name and perform an operation?
In this article, we shall learn how to add a button for each record in the GridView and perform some custom operation on click of the button.
12. How to delete multiple selected records from the GridView?
In this article, we shall learn how to delete multiple selected records from the GridView.
13. How to do custom pagination in the GridView to achieve better performance in case we have large number of data to display?
In this article, we shall learn how to do custom pagination in the GridView (Useful for listing large number of records) or to do SEO friendly pagination for the GridView.
14. How to work with the nested GridView (a GridView inside another GridView) and populate the data?
In this article, we shall learn how to work with (access) nested GridView (a GridView inside another GridView).
15. How to display mouseover effect on GridView rows using CSS?
In this article, we shall learn how to display mouseover effect on the GridView rows.
16. How to get the primary key value of the GridView rows in JavaScript or popup page?
In this article, we shall learn how to get the primary key value of the GridView records in JavaScript.
17. Saving images into the database in asp.net and displaying to the GridView
In this article, we shall learn how to save an image file (picture) into the database and show them in the GridView.
18. DropDownList in the GridView - Keeping asp.net forms control in GridView
In this article, I have described the ways of keeping DropDownList in the GridView and binding the data by preserving the default SelectedValue. Apart from DropDownList, I have also shown how to keep CheckBox, RadioButtonList, TextBox in the GridView and preserving the default data.
19. ASP.NET GridView + jQuery tips and tricks - Part 1
This article demonstrate how to do CRUD operation using GridView and jQuery seamlessly (without page refresh) and also describes some simple UI effects in ASP.NET GridView control using jQuery.
20. ASP.NET GridView + jQuery tips and tricks - Part 2
This article demonstrate how to do CRUD operation using GridView and jQuery seamlessly (without page refresh) and also describes some simple UI effects in ASP.NET GridView control using jQuery.
21. How to insert record using GridView
Generally GridView is used to show data in tabular format. It also provide ways to modify and delete records but currently there is no way to insert record using GridView. In this article, I shall describe an easy work around to insert record using GridView.
22. Updating, Deleting records using GridView control
In this article, I am going to explain how to manipulate data using GridView control. This article scope is limited to Updating and Deleting records using GridView and I am not using any readymade Data controls for that but manually writing all event methods. I will be using Sql objects directly into methods to keep the example simple and straight forward. In practical scenario you should use your existing architecture to populate and update the data.
Hope all above articles would be of great use to all of you. In case you face any other type of problems related with GridView that is not covered here, please respond to this article and I shall try to solve and publish.