a=a+b;
b=a-b;
a=a-b;
ASP.NET
Thursday 20 December 2012
fibonacci series in c sharp
using System; class Program { public static int Fibonacci(int n) { int a = 0; int b = 1; // In N steps compute Fibonacci sequence iteratively. for (int i = 0; i < n; i++) { int temp = a; a = b; b = temp + b; } return a; } static void Main() { for (int i = 0; i < 15; i++) { Console.WriteLine(Fibonacci(i)); } } }
Prime Numbers between ’0′ and ’100′ in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PrimeNumber
{
class Program
{
static void Main(string[] args)
{
bool isPrime = true;
for (int i = 1; i <= 100; i++)
{
for (int j = 2; j <= 100; j++)
{
if (i != j && i % j == 0)
{
isPrime = false;
break;
}
}
if (isPrime)
{
Console.WriteLine("Prime:" + i);
}
isPrime = true;
}
Console.ReadKey();
}
}
}
Friday 2 November 2012
Life Cycle of Master, User-control and Content page
1.Content Page PreInit Event
2.Page:UserControl Init Event
3.Master:UserControl Init Event
4.Master Page Init Event
5.Content Page Init Event
6.Content Page Load Event
7.Master Page Load Event
8.Page:UserControl Load Event
9.Master:UserControl Load Event
10.Content page prerender
11.Master Page's Page_prerender
12.Master Page's Page_Unload
13.and finally Content page's Page_Unload
Friday 15 June 2012
OOPS Concepts
What is Object Oriented Programming? It is a problem solving technique to develop software systems. It is a technique to think real world in terms of objects. Object maps the software model to real world concept. These objects have responsibilities and provide services to application or other objects. | |
What’s a Class? A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects. It’s a comprehensive data type which represents a blue print of objects. It’s a template of object. | |
What’s an Object? It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity. Objects are members of a class. Attributes and behavior of an object are defined by the class definition. | |
What is the relation between Classes and Objects? They look very much same but are not same. Class is a definition, while object is a instance of the class created. Class is a blue print while objects are actual objects existing in real world. Example we have class CAR which has attributes and methods like Speed, Brakes, Type of Car etc. Class CAR is just a prototype, now we can create real time objects which can be used to provide functionality. Example we can create a Maruti car object with 100 km speed and urgent brakes. | |
What is Abstraction? It allows complex real world to be represented in simplified manner. Example color is abstracted to RGB. By just making the combination of these three colors we can achieve any color in world.It’s a model of real world or concept. | |
What is Encapsulation? It is a process of hiding all the internal details of an object from the outside world. | |
What is Object lifetime? All objects have life time.Objects are created ,and initialized, necessary functionalities are done and later the object is destroyed. Every object have there own state and identity which differ from instance to instance. | |
What is Association? This is the simplest relationship between objects. Example every customer has sales. So Customer object and sales object have an association relation between them. | |
What is Aggregation? This is also called as composition model. Example in order to make a "Accounts" class it has use other objects example "Voucher", "Journal" and "Cash" objects. So accounts class is aggregation of these three objects. | |
What is Polymorphism? When inheritance is used to extend a generalized class to a more specialized class, it includes behavior of the top class(Generalized class). The inheriting class often implement a behavior that can be somewhat different than the generalized class, but the name of the behavior can be same. It is important that a given instance of an object use the correct behavior, and the property of polymorphism allows this to happen automatically. | |
What are abstract classes? Following are features of a abstract class :- 1. You can not create a object of abstract class. 2. Abstract class is designed to act as a base class (to be inherited by other classes). Abstract class is a design concept in program development and provides a base upon which other classes are built. 3. Abstract classes are similar to interfaces. After declaring an abstract class, it cannot be instantiated on its own, it must be inherited. 4. In VB.NET abstract classes are created using "MustInherit" keyword.In C# we have "Abstract" keyword. 5. Abstract classes can have implementation or pure abstract methods which should be implemented in the child class. | |
What is a Interface? Implementing a interface it says to the outer world, that it provides specific behavior. Example if a class is implementing Idisposable interface that means it has a functionality to release unmanaged resources. Now external objects using this class know that it has contract by which it can dispose unused unmanaged objects. Single Class can implement multiple interfaces. If a class implements a interface then it has to provide implementation to all its methods. | |
What is difference between abstract classes and interfaces? Following are the differences between abstract and interfaces :- 1. Abstract classes can have concrete methods while interfaces have no methods implemented. 2. Interfaces do not come in inheriting chain, while abstract classes come in inheritance. | |
What is a delegate? Delegate is a class that can hold a reference to a method or a function. Delegate class has a signature and it can only reference those methods whose signature is compliant with the class. Delegates are type-safe functions pointers or callbacks. | |
Do events have return type? No, events do not have return type. | |
Can event’s have access modifiers? Event’s are always public as they are meant to serve every one registering to it. But you can access modifiers in events.You can have events with protected keyword which will be accessible only to inherited classes.You can have private events only for object in that class. | |
Can we have shared events? Yes, you can have shared event’s. Note: Only shared methods can raise shared events. | |
What is shadowing? When two elements in a program have same name, one of them can hide and shadow the other one. So in such cases the element which shadowed the main element is referenced. | |
What is the difference between Shadowing and Overriding? Following are the differences between shadowing and overriding :- 1. Overriding redefines only the implementation while shadowing redefines the whole element. 2. In overriding derived classes can refer the parent class element by using "ME" keyword, but in shadowing you can access it by "MYBASE" | |
What is the difference between delegate and events? Actually events use delegates in bottom. But they add an extra layer on the delegates, thus forming the publisher and subscriber model. As delegates are function to pointers they can move across any clients. So any of the clients can add or remove events, which can be pretty confusing. But events give the extra protection by adding the layer and making it a publisher and subscriber model. 212 Just imagine one of your clients doing this c.XyzCallback = null This will reset all your delegates to nothing and you have to keep searching where the error is. | |
If we inherit a class do the private variables also get inherited? Yes, the variables are inherited but can not be accessed directly by the class interface | |
What are the different accessibility levels defined in .NET? Following are the five levels of access modifiers :- 1. Private : Only members of class have access. 2. Protected :-All members in current class and in derived classes can access the variables. 3. Friend (internal in C#) :- Only members in current project have access to the elements. 4. Protected friend (protected internal in C#) :- All members in current project and all members in derived class can access the variables. 5. Public :- All members have access in all classes and projects. | |
Can you prevent a class from overriding? If you define a class as "Sealed" in C# and "NotInheritable" in VB.NET you can not inherit the class any further. |
What is the use of "MustInherit" keyword in VB.NET? If you want to create a abstract class in VB.NET it’s done by using "MustInherit" keyword.You can not create an object of a class which is marked as "MustInherit". When you define "MustInherit" keyword for class you can only use the class by inheriting. | |
Do interface have accessibility modifier? All elements in Interface should be public. So by default all interface elements are public by default. | |
What are similarities between Class and structure? Following are the similarities between classes and structures :- 1. Both can have constructors, methods, properties, fields, constants, enumerations, events, and event handlers. 2. Structures and classes can implement interface. 3. Both of them can have constructors with and without parameter. 4. Both can have delegates and events. | |
What is the difference between Class and structure’s? Following are the key differences between them :- 1.Structure are value types and classes are reference types. So structures use stack and classes use heap. 2. Structures members can not be declared as protected, but class members can be. You can not do inheritance in structures. 3. Structures do not require constructors while classes require. 4.Objects created from classes are terminated using Garbage collector. Structures are not destroyed using GC. | |
What does virtual keyword mean? They are that method and property can be overridden. | |
What are shared (VB.NET)/Static(C#) variables? Static/Shared classes are used when a class provides functionality which is not specific to any instance. In short if you want an object to be shared between multiple instances you will use a static/Shared class. Following are features of Static/Shared classes :- 1. They can not be instantiated. By default a object is created on the first method call to that object. 2. Static/Shared classes can not be inherited. 3. Static/Shared classes can have only static members. 4. Static/Shared classes can have only static constructor. | |
What is Dispose method in .NET? NET provides "Finalize" method in which we can clean up our resources. But relying on this is not always good so the best is to implement "Idisposable" interface and implement the "Dispose" method where you can put your clean up routines. | |
What is the use of "OverRides" and "Overridable" keywords? Overridable is used in parent class to indicate that a method can be overridden. Overrides is used in the child class to indicate that you are overriding a method | |
Where are all .NET Collection classes located? System.Collection namespace has all the collection classes available in .NET. | |
What is ArrayList? Array is whose size can increase and decrease dynamically. Array list can hold item of different types. As Array list can increase and decrease size dynamically you do not have to use the REDIM keyword. You can access any item in array using the INDEX value of the array position. | |
What’s a HashTable? You can access array using INDEX value of array, but how many times you know the real value of index. Hashtable provides way of accessing the index using a user identified KEY value, thus removing the INDEX problem. | |
What are queues and stacks? Queue is for first-in, first-out (FIFO) structures. Stack is for last-in, first-out (LIFO) structures. | |
What is ENUM? It’s used to define constants. | |
What is Operator Overloading in .NET? It allows us to define/redefine the way operators work with our classes and structs. This allows programmers to make their custom types look and feel like simple types such as int and string. VB.NET till now does not support operator overloading. Operator overloading is done by using the "Operator" keyword. Note:- Operator overloading is supported in VB.NET 2005 | |
What is the significance of Finalize method in .NET? .NET Garbage collector does almost all clean up activity for your objects. But unmanaged resources (ex: - Windows API created objects, File, Database connection objects, COM objects etc) is outside the scope of .NET framework we have to explicitly clean our resources. For these types of objects .NET framework provides Object. Finalize method 218 which can be overridden and clean up code for unmanaged resources can be put in this section. | |
Why is it preferred to not use finalize for clean up? Problem with finalize is that garbage collection has to make two rounds in order to remove objects which have finalize methods. Below figure will make things clear regarding the two rounds of garbage collection rounds performed for the objects having finalized methods. In this scenario there are three objects Object1, Object2 and Object3. Object2 has the finalize method overridden and remaining objects do not have the finalize method overridden. Now when garbage collector runs for the first time it searches for objects whose memory has to free. He can see three objects but only cleans the memory for Object1 and Object3. Object2 it pushes to the finalization queue. Now garbage collector runs for the second time. He see’s there are no objects to be released and then checks for the finalization queue and at this moment it clears object2 from the memory. So if you notice that object2 was released from memory in the second round and not first. That’s why the best practice is not to write clean up Non.NET resources in Finalize method rather use the DISPOSE. | |
How can we suppress a finalize method? GC.SuppressFinalize () | |
What is the use of DISPOSE method? Dispose method belongs to IDisposable interface. We had seen in the previous section how bad it can be to override the finalize method for writing the cleaning of unmanaged resources. So if any object wants to release its unmanaged code best is to implement 220 IDisposable and override the Dispose method of IDisposable interface. Now once your class has exposed the Dispose method it’s the responsibility of the client to call the Dispose method to do the cleanup. | |
How do I force the Dispose method to be called automatically, as clients can forget to call Dispose method? Call the Dispose method in Finalize method and in Dispose method suppress the finalize method using GC.SuppressFinalize. Below is the sample code of the pattern. This is the best way we do clean our unallocated resources and yes not to forget we do not get the hit of running the Garbage collector twice. Note:- It will suppress the finalize method thus avoiding the two trip. Public Class ClsTesting Implements IDisposable Public Overloads Sub Dispose()Implements IDisposable.Dispose ' write ytour clean up code here GC.SuppressFinalize(Me) End Sub Protected Overrides Sub Finalize() Dispose() End Sub End Class | |
In what instances you will declare a constructor to be private? When we create a private constructor, we can not create object of the class directly from a client. So you will use private constructors when you do not want instances of the class to be created by any external client. Example UTILITY functions in project will have no 221 instance and be used with out creating instance, as creating instances of the class would be waste of memory. | |
Can we have different access modifiers on get/set methods of a property? No we can not have different modifiers same property. The access modifier on a property applies to both its get and set accessors. | |
we write a goto or a return statement in try and catch block will the finally block execute? The code in then finally always run even if there are statements like goto or a return statements. | |
What is Indexer? An indexer is a member that enables an object to be indexed in the same way as an array. | |
Can we have static indexer in C#? No | |
In a program there are multiple catch blocks so can it happen that two catch blocks are executed? No, once the proper catch section is executed the control goes finally to block. So there will not be any scenarios in which multiple catch blocks will be executed. | |
What is the difference between System.String and System.StringBuilder classes? System.String is immutable; System.StringBuilder can have mutable string where a variety of operations can be performed. |
Wednesday 6 June 2012
ASP.NET - .NET Interview Questions and Answers part 4
91. How many types of Cookies are available in ASP.NET?
There are two types of Cookies available in ASP.NET:
- Session Cookie - Resides on the client machine for a single session until the user does not log out.
- Persistent Cookie - Resides on a user's machine for a period specified for its expiry, such as 10 days, one month, and never.
The user can set this period manually.
92. What is the use of the Global.asax file?
The Global.asax file executes application-level events and sets application-level variables.
93. What are the Culture and UICulture values?
The Culture value determines the functions, such as Date and Currency, which are used to format data and numbers in a Web page. The UICulture value determines the resources, such as strings or images, which are loaded for a Web page in a Web application.
94. What is the difference between ASP session and ASP.NET session?
ASP does not support cookie-less sessions; whereas, ASP.NET does. In addition, the ASP.NET session can span across multiple servers.
95. Which control will you use to ensure that the values in two different controls match?
You should use the CompareValidator control to ensure that the values in two different controls match.
96. What is the difference between a page theme and a global theme?
A page theme is stored inside a subfolder of the App_Themes folder of a project and applied to individual Web pages of that project. Global themes are stored inside the Themes folder on a Web server and apply to all the Web applications on the Web server.
97. What do you mean by a neutral culture?
When you specify a language but do not specify the associated country through a culture, the culture is called as a neutral culture.
98. What is the use of the <sessionState> tag in the web.config file?
The <sessionState> tag is used to configure the session state features. To change the default timeout, which is 20 minutes, you have to add the following code snippet to the web.config file of an application:<sessionState timeout="40"/>
99. Can you post and access view state in another application?
Yes, you can post and access a view state in other applications. However, while posting a view state in another application, the PreviousPage property returns null.
100. Which method do you use to kill explicitly a users session?
The Session.Abandon() method kills the user session explicitly.
101. Which class is inherited when an ASP.NET server control is added to a Web form?
The System.Web.UI.WebControls class is inherited when an ASP.NET server control is added to a Web form.
102. What events are fired when a page loads?
The following events fire when a page loads:
- Init() - Fires when the page is initializing.
- LoadViewState() - Fires when the view state is loading.
- LoadPostData() - Fires when the postback data is processing.
- Load() - Fires when the page is loading.
- PreRender() - Fires at the brief moment before the page is displayed to the user as HTML.
- Unload() - Fires when the page is destroying the instances of server controls.
103. Write three common properties of all validation controls.
Three common properties of validation controls are as follows:
- ControlToValidate - Provides a control to validate
- ErrorMessage - Displays an error message
- IsValid - Specifies if the control's validation has succeeded or not
- Text - Displays a text for validation control before validation
104. What are navigation controls? How many navigation controls are there in ASP.NET 4.0?
Navigation controls help you to navigate in a Web application easily. These controls store all the links in a hierarchical or drop-down structure; thereby facilitating easy navigation in a Web application.
There are three navigation controls in ASP.Net 4.0.
- SiteMapPath
- Menu
- TreeView
105. What happens if an ASP.NET server control with event-handling routines is missing from its definition?
The compilation of the application fails.
106. What are server-side comments?
Server-side comments are included in an ASP.NET page for the purpose of documentations as shown in the following code snippet:
<%--This is an example of server-side comments --%>
The server-side comments begin with <%-- and end with --%>.
107. How can we provide the WebParts control functionality to a server control?
We can provide the WebParts controls functionality to a server control by setting the CreateWebPart property of WebPartManger.
108. How do you prevent a validation control from validating data at the client end?
You can prohibit a validation control to validate data at the client side by setting the EnableClientScriptproperty to False.
109. What is cross-page posting in ASP.NET?
The Server.Transfer() method is used to post data from one page to another. In this case, the URL remains the same. However, in cross page posting, data is collected from different Web pages and is displayed on a single page. To do so, you need to set the PostBackUrl property of the control, which specifies the target page. In the target page, you can access the PreviousPage property. For this, you need to use the@PreviousPageType directive. You can access the controls of previous page by using the FindControl()method.
110. Which ASP.NET configuration options are supported in the ASP.NET implementation on the shared Web hosting platform?
There are many ASP.NET configuration choices, which are not able to configure at the site, application, or child directory level on the shared hosting environment. Some options can produce security, performance, and stability problem to the server and therefore cannot be changed.
The following settings are the only ones that can be changed in the web.config file(s) of your Web site:
- browserCaps
- clientTarget
- pages
- customErrors
- globalization
- authorization
- authentication
- webControls
- webServices
111. Explain the Application and Session objects in ASP.NET.
Application state is used to store data corresponding to all the variables of an ASP.NET Web application. The data in an application state is stored once and read several times. Application state uses theHttpApplicationState class to store and share the data throughout the application. You can access the information stored in an application state by using the HttpApplication class property. Data stored in the application state is accessible to all the pages of the application and is the same for all the users accessing the application. The HttpApplicationState class provides a lock method, which you can use to ensure that only one user is able to access and modify the data of an application at any instant of time.
Each client accessing a Web application maintains a distinct session with the Web server, and there is also some specific information associated with each of these sessions. Session state is defined in the<sessionState> element of the web.config file. It also stores the data specific to a user session in session variables. Different session variables are created for each user session. In addition, session variables can be accessed from any page of the application. When a user accesses a page, a session ID for the user is created. The session ID is transferred between the server and the client over the HTTP protocol using cookies.
112. How will you differentiate a submaster page from a top-level master page?
Similar to a content page, a submaster page also does not have complete HTML source code; whereas, a top-level master page has complete HTML source code inside its source file.
113. What are Web server controls in ASP.NET?
The ASP.NET Web server controls are objects on the ASP.NET pages that run when the Web page is requested. Many Web server controls, such as button and text box, are similar to the HTML controls. In addition to the HTML controls, there are many controls, which include complex behavior, such as the controls used to connect to data sources and display data.
114. What is the difference between a HyperLink control and a LinkButton control?
A HyperLink control does not have the Click and Command events; whereas, the LinkButton control has these events, which can be handled in the code-behind file of the Web page.
115. What are the various ways of authentication techniques in ASP.NET?
There are various techniques in ASP.NET to authenticate a user. You can use one of the following ways of authentication to select a built-in authentication provider:
- Windows Authentication - This mode works as the default authentication technique. It can work with any form of Microsoft Internet Information Services (IIS) authentication, such as Basic, Integrated Windows authentication (NTLM/Kerberos), Digest, and certificates. The syntax of Windows authentication mode is given as follows: <authentication mode="windows" />
- Forms Authentication - You can specify this mode as a default authentication mode by using the following code snippet: <authentication mode="Forms"/>
- Passport - This mode works with Microsoft Passport authentication, as shown in the following code snippet: <authentication mode = "Passport"/>
116. What are the different ways to send data across pages in ASP.NET?
The following two ways are used to send data across pages in ASP.NET:
- Session
- Public properties
117. What does the WebpartListUserControlPath property of a DeclarativeCatalogPart control do?
The WebpartListUserControlPath property sets the route of the user defined control to aDeclarativeCatalogPart control.
118. What do you mean by the Web Part controls in ASP.NET?
The Web Part controls are the integrated controls, which are used to create a Web site. These controls allow the users to change the content, outlook, and state of Web pages in a Web browser.
119. What type of the CatalogPart control enables users to restore the Web Parts that have been removed earlier by the user?
The PageCatalogPart control.
120. What is the use of web.config? What is the difference between machine.config and web.config?
ASP.NET configuration files are XML-based text files for application-level settings and are saved with the name web.config. These files are present in multiple directories on an ASP.NET Web application server. Theweb.config file sets the configuration settings to the directory it is placed in and to all the virtual sub folders under it. The settings in sub directories can optionally override or change the settings specified in the base directory.
The difference between the web.config and machine.config files is given as follows:
- <WinDir>\Microsoft.NET\Framework\<version>\config\machine.config provides default configuration settings for the entire machine. ASP.NET configures IIS to prohibit the browser directly from accessing the web.config files to make sure that their values cannot be public. Attempts to access those files cause ASP.NET to return the 403: Access Forbidden error.
- ASP.NET uses these web.config configuration files at runtime to compute hierarchically a sole collection of settings for every URL target request. These settings compute only once and cached across further requests. ASP.NET automatically checks for changing file settings and do not validate the cache if any of the configuration changes made.
121. Explain the concept of states in ASP.NET.
State is quite an innovative concept in Web development because it eliminates the drawback of losing state data due to reloading of a Web page. By using states in a Web application, you can preserve the state of the application either at the server or client end. The state of a Web application helps you to store the runtime changes that have been made to the Web application. For example, as already described earlier, a change in the data source of the Web application might be initiated by a user when he/she selects and saves some products in the shopping cart.
If you are not using states, these changes are discarded and are not saved. You may think that the whole concept of storing states is optional. However, under certain circumstances, using states with applications is imperative. For example, it is necessary to store states for Web applications, such as an e-commerce shopping site or an Intranet site of a company, to keep track of the requests of the users for the items they have selected on the shopping site or the days requested for vacation on the Intranet site.
122. Can we validate a DropDownList by RequiredFieldValidator?
Yes, we can validate a DropDownList by RequiredFieldValidator. To perform this validation, we have to set the InitialValue property of RequiredFieldValidator control.
ASP.NET - .NET Interview Questions and Answers Part 3
61. What do you understand by aggregate dependency?
Aggregate dependency allows multiple dependencies to be aggregated for content that depends on more than one resource. In such type of dependency, you need to depend on the sum of all the defined dependencies to remove a data item from the cache.
62. How can you ensure that no one has tampered with ViewState in a Web page?
To ensure that no one has tampered with ViewState in a Web page, set the EnableViewStateMac property to True.
63. What is the difference between adding items into cache through the Add() method and through theInsert() method?
Both methods work in a similar way except that the Cache.Add() function returns an object that represents the item you added in the cache. The Cache.Insert() function can replace an existing item in the cache, which is not possible using the Cache.Add() method.
64. Explain the cookie less session and its working.
ASP.NET manages the session state in the same process that processes the request and does not create a cookie. It is known as a cookie less session. If cookies are not available, a session is tracked by adding a session identifier to the URL. The cookie less session is enabled using the following code snippet:<sessionState cookieless="true" />
65. What is a round trip?
The trip of a Web page from the client to the server and then back to the client is known as a round trip.
66. What are the major built-in objects in ASP.NET?
The major built-in objects in ASP.NET are as follows:
- Application
- Request
- Response
- Server
- Session
- Context
- Trace
67. Where should the data validations be performed-at the client side or at the server side and why?
Data validations should be done primarily at the client side and the server-side validation should be avoided because it makes server task overloaded. If the client-side validation is not available, you can use server-side validation. When a user sends a request to the server, the validation controls are invoked to check the user input one by one.
68. Why do we need nested master pages in a Web site?
When we have several hierarchical levels in a Web site, then we use nested master pages in the Web site.
69. How can you dynamically add user controls to a page?
User controls can be dynamically loaded by adding a Web User Control page in the application and adding the control on this page.
70. What is the appSettings Section in the web.config file?
The web.config file sets the configuration for a Web project. The appSettings block in configuration file sets the user-defined values for the whole application.
For example, in the following code snippet, the specified ConnectionString section is used throughout the project for database connection:
<configuration>
<appSettings>
<add key="ConnectionString" value="server=indiabixserver; pwd=dbpassword; database=indiabix" />
</appSettings>
...
For example, in the following code snippet, the specified ConnectionString section is used throughout the project for database connection:
<configuration>
<appSettings>
<add key="ConnectionString" value="server=indiabixserver; pwd=dbpassword; database=indiabix" />
</appSettings>
...
71. What type of code, client-side or server-side, is found in a code-behind file of a Web page?
A code-behind file contains the server-side code, which means that the code contained in a code-behind file is executed at the server.
72. To which class a Web form belongs to in the .NET Framework class hierarchy?
A Web form belongs to the System.Web.UI.Page class.
73. What does the "EnableViewState" property do? Why do we want it On or Off?
The EnableViewState property enables the ViewState property on the page. It is set to On to allow the page to save the users input between postback requests of a Web page; that is, between the Request and corresponding Response objects. When this property is set to Off, the page does not store the users input during postback.
74. Which event determines that all the controls are completely loaded into memory?
The Page_Load event determines that all the controls on the page are fully loaded. You can also access the controls in the Page_Init event; however, the ViewState property does not load completely during this event.
75. What is the function of the CustomValidator control?
It provides the customize validation code to perform both client-side and server-side validation.
76. What is Role-based security?
In the Role-based security, you can assign a role to every user and grant the privilege according to that role. A role is a group of principal that restricts a user's privileges. Therefore, all the organization and applications use role-based security model to determine whether a user has enough privileges to perform a requested task.
77. Which data type does the RangeValidator control support?
The data types supported by the RangeValidator control are Integer, Double, String, Currency, and Date.
78. What are the HTML server controls in ASP.NET?
HTML server controls are similar to the standard HTML elements, which are normally used in HTML pages. They expose properties and events that can be used programmatically. To make these controls programmatically accessible, you need to specify that the HTML controls act as a server control by adding the runat="server"attribute.
79. Why a SiteMapPath control is referred to as breadcrumb or eyebrow navigation control?
The SiteMapPath control displays a hierarchical path to the root Web page of the Web site. Therefore, it is known as the breadcrumb or eyebrow navigation control.
80. Where is the ViewState information stored?
The ViewState information is stored in the HTML hidden fields.
81. Which namespaces are necessary to create a localized application?
The System.Globalization and System.Resources namespaces are essential to develop a localized application.
82. What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?
You can select more than one HtmlInputCheckBox control from a group of HtmlInputCheckBox controls; whereas, you can select only a single HtmllnputRadioButton control from a group ofHtmlInputRadioButton controls.
83. What is the difference between HTML and Web server controls?
HTML controls are client-side controls; therefore, all the validations for HTML controls are performed at the client side. On the other hand, Web server controls are server-side controls; therefore, all the validations for Web server controls are performed at the server side.
84. Explain the AdRotator Control.
The AdRotator is an ASP.NET control that is used to provide advertisements to Web pages. The AdRotatorcontrol associates with one or many advertisements, which randomly displays one by one at a time when the Web page is refreshed. The AdRotator control advertisements are associated with links; therefore, when you click on an advertisement, it redirects you to other pages.
The AdRotator control is associated with a data source, which is normally an xml file or a database table. A data source contains all the information, such as advertisement graphics reference, link, and alternate text. Therefore, when you use the AdRotator control, you should first create a data source and then associate it with the AdRotator control.
The AdRotator control is associated with a data source, which is normally an xml file or a database table. A data source contains all the information, such as advertisement graphics reference, link, and alternate text. Therefore, when you use the AdRotator control, you should first create a data source and then associate it with the AdRotator control.
85. What do you understand by the culture?
The culture denotes a combination of a language and optionally a region or a country. The contents of a Web page of a multilingual Web site are changed according to the culture defined in the operating system of the user accessing the Web page.
86. What is the difference between absolute expiration and sliding-time expiration?
The absolute expiration expires a cached item after the provided expiration time. The sliding time does not expire the cached items because it increments the specified time.
87. What is the code-behind feature in ASP.NET?
The code-behind feature of ASP.NET enables you to divide an ASP.NET page into two files - one consisting of the presentation data, and the second, which is also called the code-behind file, consisting of all the business logic. The presentation data contains the interface elements, such as HTML controls and Web server controls, and the code-behind contains the event-handling process to handle the events that are fired by these controls. The file that contains the presentation data has the .aspx extension. The code behind file has either the .cs extension (if you are using the programming language C#) or the .vb (if you are using the programming language Visual Basic .NET) extension.
88. How can you check if all the validation controls on a Web page are valid and proper?
You can determine that all the validation controls on a Web page are properly working by writing code in the source file of the Web page using a scripting language, such as VBScript or JavaScript. To do this task, you have to loop across validators collection of pages and check the IsValid property of each validation control on the Web page to check whether or not the validation test is successful.
89. Explain the validation controls. How many validation controls in ASP.NET 4.0?
Validation controls are responsible to validate the data of an input control. Whenever you provide any input to an application, it performs the validation and displays an error message to user, in case the validation fails.
ASP.NET 4.0 contains the following six types of validation controls:
ASP.NET 4.0 contains the following six types of validation controls:
- CompareValidator - Performs a comparison between the values contained in two controls.
- CustomValidator - Writes your own method to perform extra validation.
- RangeValidator- Checks value according to the range of value.
- RegularExpressionValidator - Ensures that input is according to the specified pattern or not.
- RequiredFieldValidator - Checks either a control is empty or not.
- ValidationSummary - Displays a summary of all validation error in a central location.
90. What is difference between a Label control and a Literal control?
The Label control's final html code has an HTML tag; whereas, the Literal control's final html code contains only text, which is not surrounded by any HTML tag.
Subscribe to:
Posts (Atom)