ASP.NET interview Question- Part3

  1. Difference between Const and readonly?
  • const cannot be static, readonly can be static.
  • Evaluation of the values of const  is done during design time.
  • A const required to be declared and initialized during declaration.

2. How can you show the number of visitors of your app?
By making use of the application variable and increment the counter beginning of each session.
Session start and Application_start event can be used.

3. What are the navigation controls available with
Navigation controls available are
Tree views
Site Maps

4. Which two properties on validation control?
The common properties available in every validation control are
Error Message
Control to validate

5. Which method do you use to redirect the user to another page without performing a round trip to the client?
Server. Transfer can be used to redirect the user directly to another page without any round trip to the client.

6. What is web.config file?
Web.config is the configuration file for ASP.NET application. There is one web.config file in application which configures
the particular application. Web.config file is written in XML with specific tags having specific meanings.It includes data which includes
connections,Session States,Error Handling,Security etc.

7. What are the various ways of securing a web site that could prevent from hacking?
Various ways of securing the web sites from hackers are as follows:-
Encryption/ Decryption
Maintaining the server inside corporate firewall

8. What are the different types of directives in .NET?
Different types of directives are as follows:-

9. What is Page Directive?
Defines page-specific attributes used by the ASP.NET page parser and compiler. Can be included only in .aspx files and also define the page language used just like c#,VB etc. <%@ Page AspCompat=”TRUE” language=”C#” %>

10. How to customize the Appearance of SiteMapPath web server controls?
The appearance can be customized by setting the attributes of the control alse by configuring the templates which are available for the control.

11. What is PostBack?
The process that sends the web page data back to the server of the same page is called PostBack.

12. What is the code to remove all the items from the session?
Session.Contents.RemoveAll() is the code used to remove all the items from the seesion.

13. What is Reference Directive?
Declaratively indicates that another user control or page source file should be dynamically compiled and linked against the page in which this directive is declared.

14. Can you add title to the browser history point?
Yes, it is possible to add title in the browser history point.

15. Can you display image with hyperlink field of gridview?
<asp:GridView ID=”GridView1″ runat=”server”>
<asp:HyperLinkField Text=”<img src=’1.gif’/>” />

16. What is CauseValidation Property in ASP.NET?
CausesValidation property determines whether validation must be performed on button click or not, if validation control are used. It can be either true or false. By default it is true. It is mostly used for Cancel/Reset button, where we don’t want to perform any kind of validations.

17. Can you access controls placed in master page in content page?
It is possible to access control in Master page. FindControl method is used for Master Page Class.

18. What are the parts of Master Page?
Master Page consist of three parts:-
1. The area for Master Page content
2. Area for the child Page, which is replace by child pages content.

19. Tel us the different ways to apply CSS in web page?
Three different ways to apply CSS are
1. Create a style sheet file and define all your styles and just provide the reference of the style sheet page in the head section using link tag.
2. Define style in head element of your page and use that styles in your page.
3. Define style inline. Inline style means add style attribute to particular HTML element.

20. What should be done to avoid Script Injection?
Steps to be followed to avoid Script Injection:-
Restrict the user from entering <, >  as input character.
Encode the input before storing.


Please enter your comment!
Please enter your name here