Chapter 5

 ASP.NET (Using Visual Basic.Net)

Q.1. Fill in the Blanks
1. The ___ is a software technology that is accessible with latest Microsoft window operating system.
Ans- .NET Framework.
2. CLS stand for- Ans- Common Language Specification.
3. CLR stand for- Ans- Common Language Runtime.
4. FCL stand for –Ans- Framework Class  Library.
5. The Main function of common language runtime(CLR) is to convert them___ into native code and then execute the program.
Ans- managed code.
6. The___ argument of Server variables collection returns the method used to make the request.
Ans- HTTP_METHOD.
7.  The___ argument of Server variables collection returns the string describing browser that sends the request.
Ans- HTTP_AGENT.
8. The___ argument of Server variables collection returns the encoded URL.
Ans- HTTP_URL.
9. The___ argument of Server variables collection returns the IP Address of the remote host making request.
Ans- REMOTE_HOST.
10.The ___ method converts an object to its string representation.
Ans- ToString.
11. ___ is stored in memory on the server and is faster than storing and retrieving information in a database.
Ans- Application State.
12. The ___ class is most often accessed through the application property of the Http Context Class.
Ans- HttpApplicationState.
13. The ___ retains no knowledge of variable values that were used during previous requests.
Ans- server.
14. A___ is a small bit of text or small amount of data that is stored either in a text file on the client files system or in-memory in the client browser session.
Ans- cookie.
15.The ___ checks the user’s input based upon a lower & upper range of numbers or characters.
Ans- Range Validator.
16. The___allows  for comparisons between the input and another item.
Ans- Compare Validator.
17. The ___ method sends all buffered output to the client.
And- Flush.
18. Two types of ___ are Client-based State management and Server-based state management.
Ans- State managements.
19. ___which stores variables that can be accessed by all users of an ASP.Net application.
Ans-Application State.
20. ___which persists values in apage.
Ans-View State.
Q. 2. State True or False.
1. The .Net Framework is a platform that provides tools & technologies needed to build network application.
Ans-True.
2. ASP.Net is technology for building Dynamic Web Application.
Ans-True.
3. The Control class implements basic functionality required by classes that display information to the user.
Ans-True.
4. The Htmlinputfile control is used as html<input type=file >elements.
Ans-True.
5. The flush method clears all content output from buffer stream.
Ans-False.
6. The cookies property gets the response cookies collection.
Ans-True.
7. Http Request enables asp.net to read and the HTTP values sent by a client during a web request.
8. True.
9. The HttpState object is a container class for all the objects.
Ans-False.
10. View state, which  persist values in a page.
Ans-True.
11. ASP.Net has window view option t display multiple files.
Ans-False.
12. Web server controls are Hypertext Markup Language elements.
Ans-False.
13. Tree view is one of the valid view available in visual studio.Net.
Ans-True.
14. In ASP.Net a web server control uses run attribute for execution.
Ans-False.
15. Session state applies to all users and sessions.
Ans-False.
16. ASP.Net pages are stored in client side.
Ans-False.
17. The value of a constant cannot be changed anywhere in a code.
Ans-True.
18. Code-behind pages are unrelated with web forms.
Ans-Flase.
19. Server side scripting is commonly written using ASP.Net technology.
Ans-Ture.
20. @ application directive can be used only in Global.asax files, while the other directives are used in other ASP.Net files such as web pages (.aspx files) anduser controls (.asex files).
Ans-True.
21. The source attribute specifies path & file name of external script file.
Ans-False.
22. ASP.Net files have the extension .aspxf.
Ans-False.
23. The Visual Studio .Net code editor is also known as the text editor.
Ans-True.
24. Web application is application that uses a web browser as a client.
Ans-True.
25. The server is used in Client-server environment to run the application.
Ans-False.
Q.3. Multiple Choice Question Single Correct. (One Correct).
Note:- (Bold Option is Answers  of Question)
1. The ___ is Microsoft’s Managed Code programming model for building application on window clients, servers, and mobile or embedded devices.
a. Framework              b. Web Network         c. .Net Framework    d. Frame
2. ___ is a technology for building dynamic web application.
a. ASP.NET               b. .NET                                   c. VB.NET                  d. .Net Technology
3. ___ provides you with tools to help track  down errors in your ASP.Net web pages.
a. Visual Web developer       b. Visual Web debugger         c. Complier      d. Interpreter
4. The___ which allows to step through the page’s code line by line and examine the values of variables.
a. Compiler                  b. Interpreter               c. Code window         d. Debugger
5. After debugging the now click the run button on the toolbar or hit the___ key to run the application.
a. F6                            b. F1                            c. F4                            d. F5
6. The Visual Studio.Net Code editor is also called as ___
a. Text Editor                        b. Text Viewer                        c. Text Container        d. Text Display
7. The___ control display a textbox for user input.
a. Textbox                  b. Textarea                  c. Textcontrol              d.Box
8. The___ control display radio button.
a. Checkbox                b. CheckboxList          c. Textcontral              d. RadioButton
9. The___ control is used as html <input type=file> element.
a. HtmlButoon                        b.HtmlAnchor             c. HtmlInputFile        d. HtmlInputCheckbox
10. ___ is testing process to determine whether value entered by vistor into field is valid or not.
a. Validate                   b. Validation              c. Testing                     d. Checking
11. ___ enables ASP.Net to read and the HTTP values sent by a client during a web request.
a. Http Response         b. Http Server             c. Http Request          d. Server
12. The___ argument of server variables collection returns the encoded URL.
a. HTTP_COOKIE     b. HTTP_HOST                      c. HTTP_URL                       d. HTTP_VERSION
13. The___ resource is available in visual studio server explorer tool.
a. Database connection         b. Tree             c. Event                       d. Class
14. ASP Stand for___.
a. Active Site Page      b. All Server Pages      c. Active Server Pages           d. None of these
15. In VB.Net, to declare variables,___ keyword is used.
a. Dim                         b. Char                                    c. Explicit                    d. None
16. ___ is a reusable piece of code that contains related data and function.
a. Object                     b. Properties                c. Methods                  d. Variable
17. In .Net Framework ___ method of response object sends all buffered output to the client and stop execution of the page.
a. Flush                        b. Stop                         c. Clear                                    d. End
18. In Visual Studio, Solution explorer provides____           view of the project and their files.
a. Organized              b. Tree                         c. Compact                  d. Link
19. In .Net framework ____ web server control is used to insert the image when a hot spot region is defined.      
a. Image                      b. Textbox                   c. Imagemap              d. Hyperlink
20. Modules are ___ function witch perform a specific task.
a. built-in                     b. user-defined           c. Selected                   d. Local
21. ASP.Net coding technique contains single file and ____.
a. Program                   b. Double code            c. Code behind           d. Double file
22. In visual studio____ window displays different types of editing fields to set name, font etc.
a. Class                                    b. Project                     c. Properties               d. Tree
23. ___ state is data repository available to all classes in ASP.Net application.
a. Application                        b. Session                    c. Response                 d. Request
24. In ASP.Net page framework supports ____ directory.
a. Href                         b. Name           c. Code-generator block          d. Code-declaration block
25. ___ is a validation server control in ASP.Net.
a. Compiler                  b. Compare Validator                       c. Control Validator    d. Server Control
26. ___ is a validation server control in ASP.Net.
a. Range                      b. Level                       c. Range Validator                d. Level Validator
27. ___ is the shortcut to reponse.write.
a. <!=>                        b. <%=…%>             c.<=>                           d. <*=>
28. ___ is used as web server control in .Net Framework.
a. Popup                      b. TextArea                 c. Password                 d. HiddenField
29. ___ is the heart and soul of .Net framework.
a. Base Class               b. Form                        c. ADO.Net                d. CLR
30. ASP.Net is used to create___ web pages.
a. Dynamic                 b. Static                       c. Both                                    d. None
31. The ___ object provides a set of method & Properties through which we can obtain the local server.
a. HttpObject              b. HttpserverUtility   c. HttpRequest            d. HttpSession
32. By default ____ session state is enabled for all ASP.Net application.
a. ASP.Net                 b. ASP                         c. AJAX                                  d. JS   

Q.4. Multiple Choice Question Two Correct. (Two Correct).
Note:- (Bold Option is Answers  of Question)
1. Web application uses a combination of ___ & ___ language to develop the application.
a. Server side             b. Application side                  c. Client Side              d. Computer side e. Client server side
2. The main Components of .Net Framework are___.
a. Namespace              b. Programming Model           c. CLR                                    d. scripting mode e. FCL
3. Following are the attributes of @ page directive ____.
a. Buffer                     b. Classname                          c. runat                        d. Lnaguage       e. Source
4. Following are the HTML Server Controls.
a. Radiobutton           b. HtmlAnchor                                    c. HtmlTextarea         d. Image           e. Checkbox  

5. The Properties of window tab are___.
a. Object Name          b. Object browser                    c. Window                  d. Events
6. Following are the serverside objects.
a. Page Object                        b. HttpResponseObject         c. Query Object           d. Run Object
e. Choice Object
7. The System.Web namespase supplies ___ and ___ that enables browser server communication.
a. Methods                  b. Classes                    c. Interfaces               d. Objects        e. Event
8.  The Validation Server Controls in ASP.Net are.
a. Compare Validator           b. Range Validator    c. View Validator       d. Select Validator e.Select Choice Validator.
9. Source View provides the following advantages over Design View.
a. Format the document       b. Edit Page Directives          c. Choosing Close File                             d. Option dialog of Tools menu              e. Choosing Close File.
10. Following are the attributes of <script> tag.
a. Language               b. Runat                     c. Title             d. Buffer                     e. Http
11. Following are the ASP.Net Programming Language.
a. VB.Net                   b. MVC                                   c. Visual C#    d. Web Forms             e. C#

Q.5. Multiple Choice Question Two Correct. (Three Correct).
Note:- (Bold Option is Answers  of Question)
1.      The Properties of window tab are.
a. Object Name                b. Object Browser                   c. Window                  d. Events
e. Property Pages                        f. Language
2. Following are the three panes of object browser.
a. View Pane              b. Object Pane             c. Member Pane          d. Description Pane  
e. Display Pane.
3. Following are the web server control.
a. HtmlSelect              b. Hyperlink               c. Imagemap              d. HtmlRadio             
e. Image                      f. HTML change.
4. Following are the Server-side objects.
a. HttpApplicationState Object        b. HtmlSessionObject                    c. HttpServerUtility Object
d. Http Object             e. HttpClient Object               f. Choice Object.
5. Following are the HTML Server Controls.
a. HtmlInputText      b. HtmlInputButton              c. HtmlForm              d. Checkbox   
e. DropDownList        f. Hyperlink

Q.7. Short answer questions.(2 Marks)
1.      What is a cookie?
Cookies are usually small text files, given ID tags that are stored on your computer's browser directory or program data subfolders. Cookies are created when you use your browser to visit a website that uses cookies to keep track of your movements within the site, help you resume where you left off, remember your registered login, theme selection, preferences, and other customization functions. The website stores a corresponding file(with same ID tag)to the one they set in your browser and in this file they can track and keep information on your movements within the site and any information you may have voluntarily given while visiting the website, such as email address.
2.      What is session? Give use of session state?
A Session object stores information about, or change settings for a user session. When you are working with an application on your computer, you open it, do some changes and then you close it. This is much like a Session. The computer knows who you are. It knows when you open the application and when you close it. However, on the internet there is one problem: the web server does not know who you are and what you do, because the HTTP address doesn't maintain state.ASP solves this problem by creating a unique cookie for each user. The cookie is sent to the user's computer and it contains information that identifies the user. This interface is called the Session object.The Session object stores information about, or change settings for a user session.


3.      Explain application state.
Application state is a data repository available to all classes in an ASP.NET
Application. Application state is stored in memory on the server and is faster than storing and retrieving information in a database. Unlike session state, which is specific to a single user session, application state applies to all users and sessions. Therefore, application state is a useful place to store small amounts of often-used data that does not change from one user to another. For information on saving data on a per-user basis see Session State Overview and ASP.NET Profile Properties Overview.

4.      Give an explanation of any four server variables.

AUTH_PASSWORD
Returns the value entered in the client's authentication dialog
AUTH_TYPE
The authentication method that the server uses to validate users
AUTH_USER
Returns the raw authenticated user name
CERT_COOKIE
Returns the unique ID for client certificate as a string


Definition -
1)      CLS-(Common Language Specification )
 The Common Language Specification is set of language features that.Net Languages need to develop Applications and services which are supported by the Common Language Runtime (CLR).
2)      FCL(Framework Class Library)-
The .NET Framework has large groups of predefined classes, known as the .NET Framework Class Library. (FCL)           
3)      CLR- (Common Language Runtime)
The .NET framework provides a run-time environment called the Common Language Runtime which runs the code and provides services that make the development process faster.

Title
Description
Describes the steps required to take advantage of the common language runtime.
Describes how the garbage collector allocates and releases memory.
Describes key .NET Framework concepts such as the common type system, cross-language interoperability, managed execution, application domains, and assemblies.
Describes how types are declared, used, and managed in the runtime in support of cross-language integration.
  
              
.Net Framework Architecture Diagram
Advantages of ASP.Net-
1. ASP.NET drastically reduces the amount of code required to build large applications.
2. With built-in Windows authentication and per-application configuration, your applications are safe and secured.
3. It provides better performance by taking advantage of early binding, just-in-time compilation, native optimization, and caching services right out of the box.
4. The ASP.NET framework is complemented by a rich toolbox and designer in the Visual Studio integrated development environment. WYSIWYG editing, drag-and-drop server controls, and automatic deployment are just a few of the features this powerful tool provides.
5. Provides simplicity as ASP.NET makes it easy to perform common tasks, from simple form submission and client authentication to deployment and site configuration.
6. The source code and HTML are together therefore ASP.NET pages are easy to maintain and write. Also the source code is executed on the server. This provides a lot of power and flexibility to the web pages.
7. All the processes are closely monitored and managed by the ASP.NET runtime, so that if process is dead, a new process can be created in its place, which helps keep your application constantly available to handle requests.
8. It is purely server-side technology so, ASP.NET code executes on the server before it is sent to the browser.
9. Being language-independent, it allows you to choose the language that best applies to your application or partition your application across many languages.
10. ASP.NET makes for easy deployment. There is no need to register components because the configuration information is built-in.
11. The Web server continuously monitors the pages, components and applications running on it. If it notices any memory leaks, infinite loops, other illegal activities, it immediately destroys those activities and restarts itself.
12. Easily works with ADO.NET using data-binding and page formatting features. It is an application which runs faster and counters large volumes of users without having performance problems.
ASP.NET Coding techniques Single File and Code Behind
Code Behind
Single File
The HTML and controls are in the .aspx file, and the code is in a separate .aspx.vb or .aspx.cs file.
The code is in <script> blocks in the same.aspx file that contains the HTML and controls.
The code for the page is compiled into a separate class from which the .aspx file derives.
The .aspx file derives from the Page class.
All project class files (without the .aspx file itself) are compiled into a .dll file, which is deployed to the server without any source code. When a request for the page is received, then an instance of the project .dll file is created and executed.
When the page is deployed, the source code is deployed along with the Web Forms page, because it is physically in the .aspx file. However, you do not see the code, only the results are rendered when the page runs.

Visual Studio .NET Server Explorer-
The Following resources are-


1.      Database Connection.
2.      Servers.
3.      Crystal Report
4.      Event Logs
5.      Message Queues
6.      Performance Counters
7.      Windows Services


Visual Studio .NET Solution Explorer-View Type are following-


1.      Tree View      
2.      Class View
3.      Design View
4.      Source View


Visual Studio .Net Properties View- The properties of window tab are given below-


1.      Object Name
2.      Categorized
3.      Alphabetic
4.      Property Pages
5.      Properties
6.      Events


7.       
Web Server Controls in ASP.NET-


1. TextBox.
2. Leble.
3. Image.
4. Imagemap.
5. DropDownList.
6. CheckBox.
7. CheckBoxList.
8. RadioButton.
9. Hyperlink.
10. HiddenField.


HTML Server Controls are-


1.      HtmlAnchor.
2.      HtmlButton.
3.      HtmlForm.
4.      HtmlGeneric.
5.      HtmlImage.
6.      HtmlInputButton.
7.      HtmlInputCheckBox.
8.      HtmlInputFile.
9.      HtmlInputHidden.
10.  HtmlInputImage.
11.  HtmlInputRadioButton.
12.  HtmlInputText.
13.  HtmlSelect.
14.  HtmlTextArea.


The Validation Server Controls in ASP.NET are-
Compare Validator – Allows for Comparisons between the users’ input  and another item using a comparison operator (equals, greater than, less than and so on).
Range Validator- Checks the user’s input base upon a lower-and upper-level range of numbers of characters.
Components and Application – Namespace -System .Web.HttpResponse. Properties are –


1.      Buffer.
2.      BufferOutput.
3.      Charset.
4.      Cookies.
5.      Expires.
6.      Headers.
7.      Output.


Namespace -System .Web.HttpResponse Methods are-


1.      Binary Write.
2.      Clear.
3.      End.
4.      Flush.
5.      Write(string).


ASP.NET Serve variables  are-


1.      HTTP_COOKIE.       
2.      HTTP_HOST.
3.      HTTP_METHOD
4.      HTTP_URL.
5.      HTTP_USER_AGENT.
6.      HTTP_VERSION.
7.      HTTP_ADDR.
8.      REMOTE_HOST.
9.      REMOTE_USER
10.  REQUEST_METHOD.
11.  SERVER_NAME.
12.  SERVER_PORT.


Methods are- 1. ToString.  2.ValidateInput.
Introduction to Application State and State Management
State Management features are as follows-


1.      View state
2.      Control state
3.      Hidden fields
4.      Cookies
5.      Query stings
6.      Application state
7.      Session state
8.      Profile Properties