Awt Demo
Awt Demo
2. The UpdatePanel control helps to divide your Web page into parts, where each part
can be updated independently.
Option A: UpdateProgress
Option B: ScriptManagerProxy
Option C: UpdatePanel
Option D: Timer
3. Decimal data type from C# is specifically used for monetary values with precision
value of 28.
Option A: Boolean
Option B: Decimal
Option C: Integer
Option D: Float
6. The Command ADO.Net object allows DataAdapters to read, add, update and delete
the records in a data source
Option A: Connection
Option B: Dataset
Option C: DataReader
Option D: Command
8. The Command object method Execute Scalar is used to Used when query returns
Single value
Option A: To retrieve array data
Option B: Used when query returns Single value
Option C: Used when more than one value is retrieved
Option D: Connection is not stable
9. All data base files are contained in App_Data folder in asp.net application
Option A: App_GlobalResources
Option B: App_Code
Option C: App_Data
Option D: App_Themes
10. Range Validator control checks the user’s input based upon a lower- and upperlevel
value of Numbers or characters:
Option A: RequiredField Validator
Option B: Compare Validator
Option C: Range Validator
Option D: Custom Validator
11. The File class provides static methods for working with files
Option A: File
Option B: FileStream
Option C: FileInfo
Option D: StreamReader
12. The acronym UDDI stands for Universal Description Discovery and Integration
Option A: Universal Description Discovery and Integration
Option B: Uniform Data Development Infrastructure
Option C: Unique Development & Design Integration
Option D: Unit Describing Discovery of Data
15. Out-of-process session state maintains the state of the server in a separate worker
process Option A: In-Process
Option B: Out-of-process
Option C: SQL Server
Option D: SampleSpc
17. Virtual and override keywords are used in c# to implement runtime polymorphism
Option A: virtual
Option B: virtual and override
Option C: new and virtual
Option D: override and new
19. Asp.net AJAX uses XMLHttpRequest object to to exchange data asynchronously with
a server:
Option A: Request
Option B: XMLHttpRequest
Option C: Response
Option D: Reference
20. Preinit is the first event of ASP.NET page, when user requests a web page Option A:
PreLoad
Option B: Load
Option C: Preinit
Option D: Init
SECTION-II
1. Explain UDDI, SOAP, and WSDL with respect to web services. What is the
difference between Web Services and WCF?
UDDI:
UDDI is an XML-based standard for describing, publishing, and finding web
services.
2. What is Page Event? Explain the Page Life Cycle of ASP.NET page with an
example.
Page Event:
At each stage of the page life cycle, the page raises some events, which could be
coded. An event handler is basically a function or subroutine, bound to the
event, using declarative attributes such as Onclick or handle.
Following are the page life cycle events:
PreInit - PreInit is the first event in page life cycle. It checks the
IsPostBack property and determines whether the page is a postback. It
sets the themes and master pages, creates dynamic controls, and gets
and sets profile property values. This event can be handled by
overloading the OnPreInit method or creating a Page_PreInit handler.
Init - Init event initializes the control property and the control tree is
built. This event can be handled by overloading the OnInit method or
creating a Page_Init handler.
InitComplete - InitComplete event allows tracking of view state. All the
controls turn on view-state tracking.
LoadViewState - LoadViewState event allows loading view state
information into the controls.
LoadPostData - During this phase, the contents of all the input fields are
defined with the <form> tag are processed.
LoadPostData - During this phase, the contents of all the input fields are
defined with the <form> tag are processed.
Load - The Load event is raised for the page first and then recursively for
all child controls. The controls in the control tree are created. This event
can be handled by overloading the OnLoad method or creating a
Page_Load handler.
LoadComplete - The loading process is completed, control event
handlers are run, and page validation takes place. This event can be
handled by overloading the OnLoadComplete method or creating a
Page_LoadComplete handler
PreRender - The PreRender event occurs just before the output is
rendered. By handling this event, pages and controls can perform any
updates before the output is rendered.
PreRenderComplete - As the PreRender event is recursively fired for all
child controls, this event ensures the completion of the pre-rendering
phase.
SaveStateComplete - State of control on the page is saved.
Personalization, control state and view state information is saved. The
HTML markup is generated. This stage can be handled by overriding the
Render method or creating a Page_Render handler.
UnLoad - The UnLoad phase is the last phase of the page life cycle. It
raises the UnLoad event for all controls recursively and lastly for the page
itself. Final cleanup is done and all resources and references, such as
database connections, are freed. This event can be handled by modifying
the OnUnLoad method or creating a Page_UnLoad handler.
Page Life Cycle of ASP.NET page
Page request - When ASP.NET gets a page request, it decides whether to
parse and compile the page, or there would be a cached version of the
page; accordingly the response is sent.
Starting of page life cycle - At this stage, the Request and Response
objects are set. If the request is an old request or post back, the
IsPostBack property of the page is set to true. The UICulture property of
the page is also set.
Page initialization - At this stage, the controls on the page are assigned
unique ID by setting the UniqueID property and the themes are applied.
For a new request, postback data is loaded and the control properties are
restored to the view-state values.
Page load - At this stage, control properties are set using the view state
and control state values.
Validation - Validate method of the validation control is called and on its
successful execution, the IsValid property of the page is set to true.
Postback event handling - If the request is a postback (old request), the
related event handler is invoked.
Page rendering - At this stage, view state for the page and all controls are
saved. The page calls the Render method for each control and the output
of rendering is written to the OutputStream class of the Response
property of page.
Unload - The rendered page is sent to the client and page properties,
such as Response and Request, are unloaded and all cleanup done.
3. What is state management? Explain different ways to handle at client and Server
side in ASP.NET?
State Management:
State management maintains and stores the information of any user till the end
of the user session.
ASP.NET State management is a preserve state control and object in an
application because ASP.NET web applications are stateless. A new instance of
the Web page class is created each time the page is posted to the server. If a user
enters information into a web application, that information would be lost in the
round trip from the browser.
Different ways to handle at client and Server side in ASP.NET:
Server side
Session
Session is a very important technique to maintain state. Normally session is used
to store information and identity. The server stores information using Sessionid.
Set User Session
1. protected void btnSubmit_Click(object sender, EventArgs e)
2. {
3. Session["UserName"] = txtName.Text;
4.
5. Response.Redirect("Home.aspx");
6. }
Session Event
Session event can be seen in project Global.asax file.
Two types of Session Events
Session_Start
The Session_start event is raised every time a new user requests without a
session ID.
1. void Session_Start(object sender, EventArgs e)
2. {
3. Session["master"] = "~/Master.master";
4. }
Session_End
The Session_End event is raised when session is ended by a user or a time out
using Session end method.
1. void Session_End(object sender, EventArgs e)
2. {
3. Response.Write("Session_End");
4. }
InProcMode
It is a default session mode and a value store in web server memory (IIS).
In this the session value stored with server start and it ends when the
server is restarted.
State Server Mode
In this mode session data is stored in separate server.
SQL Server Mode
In this session is stored in the database. It is a secure mode.
Custom Mode
Generally under session data is stored in InProc, Sql Server, State server,
etc. If you store session data with other new techniques then provide
ASP.NET.
Application
Application State is a server side management state. It is also called application
level state management. In this mainly store user activity in server memory and
application event shown in Global.asax file.
There are three types of applications in ASP.NET.
Application_Start
This event begins with domain start.
1. Void Application_Start(object sender, EventArgs e)
2. {
3. Application["AppstartMessage"] = "Welcome to CSharp Corner Develop
er Communtiy";
4. }
Application_Error
1. void Application_Error(object sender, EventArgs e)
2. {
3. // Write an unhandled error code exception
4. }
Application_ End
1. Void Application_End(object sender, EventArgs e)
2. {
3. Application["AppEndMessage"] = "Application Closed";
4. }
Cache
Cache is stored on server side. It implements Page Caching and data caching.
Cache is use to set expiration polices
Response.Cache.SetExpiresTime(DateTime.Now.AddDays(1));
Client Side
state management has the following four important parts available on the client
side:
Cookie
Cookie is a small and an important part of ASP.NET. In this store user
information, session and application. It can be created constant and temporary
and they work with browser request. Cookies are store on client side. The server
can read cookies and abstract data.
Two types of cookies are available,
Persistence
This type of cookie works with Date and time.
1. Response.Cookies["CookieName"].Value = "Test Cookies";
2. //set expire time
3. Response.Cookies["CookieName"].Expires = DateTime.Today.AddHours(1
);
Non-Persistence
This is a temporary cookie. It is created with access application and discards the
close application.
1. Response.Cookies["CookieName"].Value = "Test Cookies";
Control state
Control state technique is developed to maintain data work properly in order.
We can use view state but suppose view state is disabled by the user, the control
will not work as expected. For expected results of the control we have to use
Control State. In application, the Viewstate is by default true. Sometimes we
need to use custom control to manage application properly.
1. if (!IsPostBack)
2. {
3. lblmsg1.Text = "Welcome to C# corner";
4. lblmsg2.Text = "Welcome to C# corner community";
5. }
When two messages are displayed on a Postback event, then control which one
is displayed by using customized control state.
Hidden Field
Hidden fields are used to store value to client side. Hidden field is not displayed
on the browser, but it works on a request.
1. if (HiddenField1.Value != null)
2. {
3. int val = Convert.ToInt32(HiddenField1.Value) + 1;
4. HiddenField1.Value = val.ToString();
5. Label1.Text = val.ToString();
6. }
Viewstate
Viewstate is a very useful client side property. It is used for page level state
management. Viewstate stores any type of data and used for sending and
receiving information,
Example: Set/Get user
1. if (ViewState["UserName"] != null)
2. lblName.Text = ViewState["UserName"].ToString();
OR,
1. ViewState["UserName"] = txtUserName.Text;
Viewstate is easy to apply and does not need access to any server resources. In a
Viewstate, only store small values. Viewstate enables and disables on page level
control. It also supports Encryption and Decryption and data/value is stored in
hashed format. So we are not storing important data such as password, account
information, etc. When more data is stored in this, then the page becomes
heavy.
Query String
Query string stores the value in URL.
Response.Redirect("ShowStringValue.aspx?Username=" + txtUsername.Text);
c. FileInfo Class
The FileInfo class is used to deal with file and its operations in C#. It provides
properties and methods that are used to create, delete and read file. It uses
StreamWriter class to write data to the file. It is a part of System.IO
namespace.
FileInfo Constructors
FileInfo Properties
FileInfo Methods
d. Generics
Generics allow you to define the specification of the data type of
programming elements in a class or a method, until it is actually used in the
program. In other words, generics allow you to write a class or method that
can work with any data type.
Features of Generics
Output:
Output:
f. Master Pages
Master pages allow you to create a consistent look and behavior for all the
pages (or group of pages) in your web application.
A master page provides a template for other pages, with shared layout and
functionality. The master page defines placeholders for the content, which
can be overridden by content pages. The output result is a combination of
the master page and the content page.
The content pages contain the content you want to display.
When users request the content page, ASP.NET merges the pages to produce
output that combines the layout of the master page with the content of the
content page.
Master Page Example
<%a Master %>
<html>
<body>
<h1>Standard Header From Masterpage</h1>
<asp:ContentPlaceHolder id=”CPH1” runat=”server”>
</asp:ContentPlaceHolder>
</body>
</html>
The master page above is a normal HTML page designed as a template for
other pages.
The @ Master directive defines it as a master page.
The master page contains a placeholder tag <asp:ContentPlaceHolder> for
individual content.
The id="CPH1" attribute identifies the placeholder, allowing many
placeholders in the same master page.