ASP.NET with c

ASP.NET with c#
10
Note: Answers might have been written by students in their own
words. Examiners are requested to use their wisdom while
correcting paper.
1. Attempt any two of the following:
a Why exception handling is required? Write syntax for user define exception?
Answer:( explanation 2 marks + syntax/example 3 marks)
Exception handling:
The mechanism of Exception Handling is throwing an exception and catching it C#
uses try .... catch block. Code which may give rise to exceptions is enclosed in a try
block, and catch block catches that exception and handles it appropriately. The try
block is followed by one or more catch blocks.
Example:
Basic syntax:
try
{
//programming logic(code which may give rise to exceptions)
}
catch (Exception e)
{
//message on exception
}
finally
{
// always executes
}
try: A try block identifies a block of code for which particular exceptions will be
activated. It's followed by one or more catch blocks.
catch: A program catches an exception with an exception handler at the place in a
program where you want to handle the problem. The catch keyword indicates the
catching of an exception.
finally: The finally block is used to execute a given set of statements, whether an
exception is thrown or not thrown. For example, if you open a file, it must be closed
whether an exception is raised or not.
Example:
using System;
class tryCatch
{
public static void Main()
{
int k=0;
try
{
int n= 10/k;
Console.WriteLine(”n=” + n);
}
catch(Exception e)
{
Console .WriteLine (“Division By zero exception”);
}
Console.WriteLtne(”Statement executed after Exception because of try catch”);
}
}
Output:
Division By zero exception
Statement executed after Exception because of try catch
b Explain inheritance and polymorphism.
Answer: explanation(2 ½ marks each)
Inheritance is the concept we use to build new classes using the existing class
definitions. Through inheritance we can modify a class the way we want to create new
objects. The original class is known as base or parent class & the modified class is
known as derived or subclass or child class. The concept of inheritance facilitates
the reusability of existing code & thus improves the integrity of programs &
productivity of programmers.
Polymorphism is the ability to take more than one form.
For example, an operation may exhibit different behaviour in different situations. The
behaviour depends upon the types of data used on the operation. Polymorphism is
extensively used while implementing inheritance.
Two types
 Operator polymorphism
 Function polymorphism
c Short note on framework base class library.
Answer:
.NET supplies a library of base classes that we can use to implement applications
quickly.
We can use them by simply instantiating them & invoking their methods or by
inheriting them through derived classes, thus extending their functionality.
Much of the functionality in the base framework classes resides in the vast
namespace called System.
We can use the base classes in the system namespaces for many different tasks
including:
Input/Output Operations.
String handling.
Managing arrays, lists, maps etc.
Accessing files & file systems.
Accessing the registry.
Security.
Windowing.
Windows messages.
Database Management.
Drawing.
Managing errors & exceptions.
Connecting to the Internet.
d What is type casting? Explain the concept of Boxing and Unboxing.
Answer(Type casting 1 mark + boxing 2 marks + unboxing 2 marks)
Type casting:
Type casting is a way to convert a variable from one data type to another data type.
Boxing means the conversion of a value type on the stack to object type on the
heap.
The conversion from an object type back to a value type is known as unboxing.
Boxing (value to reference) :
When the compiler finds a value type where it needs a reference type, it creates an
object ‘box’ into which it places the value of the value type. The following code
illustrates this:
int m=100;
object om=m; //creates a box to hold m OR object om=(object)m; //C-style casting
This code will create a temporary reference_type ‘box’ for the object on heap.
Boxing operation creates a copy of the value of the m integer to the object om. Now
both the variables m & om exist but the value of om resides on the heap. This means
that the values are independent of each other.
Consider following code:
int m=10;
object om=m;
m=20;
Console.WriteLine(m); //m=20
Console.WriteLine(om); //om=10
When a code changes the value of m ,the value of om is not affected.
Unboxing :
Unboxing is the process of converting the object type back to the value type. We can
only unbox a variable that has previously been boxed.
In contrast to boxing, unboxing is an explicit operation using C-style casting.
int m=10;
object om=m; //box m
int n=(int)om; //unbox om back to an int
When performing unboxing, C# checks that the value type we request is actually
stored in the object under conversion. Only if it is, the value is unboxed.
When unboxing a value, we have to ensure that the value is large enough to hold the
value of the object.
For ex. The code
int m=500;
object om=m;
byte n=(byte)om; will produce a runtime error.
2. Attempt any two of the following:
a Explain <LINK> tag with example.
Answer:(use 1 mark + syntax 1 marks + 3 attributes-3 marks)
Explanation:
The <link> tag defines a link between a document and an external resource.
The <link> tag is used to link to external style sheets.
Syntax:
<head>
<link rel="stylesheet" type="text/css" href="theme.css">
</head
Example:
<link rel="stylesheet" type="text/css" href="default.css" />
10
Where,
rel-can be used to specify the relationship of the target of the link to the current page.
type (content-type)
type-This attribute Provides information about the content type of the destination
resource, telling wether it's an HTML document, a JPG image, an Excel document,
etc.
href (uri)-The "href" attribute specifies the destination resource, which the element is
linking to. It may specify a resource in the same website or in an external one.
b What is Garbage Collector? How it works?
Answer:
Garbage Collector:(GC-2 marks+ working 2 marks+GC.Collect() 1 mark)
In the common language runtime (CLR), the garbage collector serves as an
automatic memory manager. It provides the following benefits:
 Enables you to develop your application without having to free memory.
 Allocates objects on the managed heap efficiently.
 Reclaims objects that are no longer being used, clears their memory, and
keeps the memory available for future allocations. Managed objects
automatically get clean content to start with, so their constructors do not have
to initialize every data field.
 Provides memory safety by making sure that an object cannot use the content
of another object.
Working:
A garbage collection has the following phases:
 A marking phase that finds and creates a list of all live objects.
 A relocating phase that updates the references to the objects that will be
compacted.
 A compacting phase that reclaims the space occupied by the dead objects and
compacts the surviving objects. The compacting phase moves objects that
have survived a garbage collection toward the older end of the segment.
GC.Collect() method:
This method is used to call garbage collector explicitly. It is used to force a garbage
collection to occur at any time.
c What is CSS? Give its advantages and disadvantages.
Answer:( CSS 1 mark + advantages 2 marks+disadvantages 2 marks)
CSS: CSS stands for Cascading Style Sheets
Cascading styles sheets (CSS) give Web designers more control over the formatting
and display of their HTML documents. Styles define how to display HTML elements
Advantages:
• Style sheets save time in applying formatting or positioning to your Web pages by
enabling you to script a few lines of code rather than extensive, redundant HTML
code
• You can apply and change formatting globally.
• Style sheets allow more detailed control, such as line spacing, than HTML.
• You will need to test your Web pages with multiple browsers in order to ensure
compatibility when using style sheets.
• To change the style of an element, you only have to make an edit in one place.
• CSS has a much wider array of attributes than HTML.
Disadvantages:
• Cannot create layout
• Browser compatibility – All browsers do not support CSS
• CSS works differently on different browsers. IE and Opera supports CSS as
different logic.
d What is delegate? Explain the steps to implement delegate in C#.NET.
Answer:(delegate def 1 mark + 1 mark each step)
Delegate:
The dictionary meaning of ‘Delegates’ is “A person acting for another person”.
A delegate in C# is a class type object & is used to invoke a method that has been
encapsulated into it at the time of its creation.
Creating & using delegates involves 4 steps :
Delegate declaration
Syntax:
modifier delegate return_type delegate_name(parameters)
Delegate methods definition
Syntax:
modifier function_name(parameters)
{
//statement(s)
}
Note: signature of delegate and function must be same
Delegate instantiation
Syntax:
new delegate_type(expression);
Delegate invocation
Syntax:
Delegate_object(parameters);
3. Attempt any two of the following:
a Explain CheckBox and RadioButton web server controls in ASP.NET .
(use ½ mark each + syntax 1 marks each + imp properties 1 mark each)
Answer:
CheckBox:
A check box displays a single option that the user can either check or uncheck and
radio buttons present a group of options from which the user can select just one option.
Basic syntax for check box:
<asp:CheckBox ID= "chkoption" runat= "Server"></asp:CheckBox>
CheckBox properties:
AutoPostBack
Specifies whether the form should be posted immediately after the Checked property
has changed or not. Default is false
CausesValidation
Specifies if a page is validated when a Button control is clicked
Checked
Specifies whether the check box is checked or not
id
A unique id for the control
runat
Specifies that the control is a server control. Must be set to "server"
Text
The text next to the check box
Event:
10
OnCheckedChanged
The name of the function to be executed when the Checked property has changed
RadioButton properties:
Basic syntax for radio button:
<asp:RadioButton ID= "rdboption" runat= "Server"> </asp: RadioButton>
AutoPostBack
A Boolean value that specifies whether the form should be posted immediately after
the Checked property has changed or not. Default is false
Checked
A Boolean value that specifies whether the radio button is checked or not
id
A unique id for the control
GroupName
The name of the group to which this radio button belongs
OnCheckedChanged
The name of the function to be executed when the Checked property has changed
runat
Specifies that the control is a server control. Must be set to "server"
Text
The text next to the radio button
b Explain the different parts that constitute ASP.NET application
Answer:
Content layout (aspx file),
program logic(.cs file) and
configuration file constitute an ASP.NET application(ex.global.asax or web.config).
Content files
Content files include static text, images and can include elements from database.
Program logic
Program logic files exist as DLL file on the server that responds to the user actions.
Configuration file
Configuration file offers various settings that determine how the application runs on
the server
c What is the difference between Button and LinkButton web server controls?
Button Control:
The Button control is used to display a push button. The push button may be a submit
button or a command button. By default, this control is a submit button.
A submit button does not have a command name and it posts the page back to the
server when it is clicked. It is possible to write an event handler to control the actions
performed when the submit button is clicked.
A command button has a command name and allows you to create multiple Button
controls on a page. It is possible to write an event handler to control the actions
performed when the command button is clicked.
Basic syntax:
<asp:Button id="b1" Text="Submit" runat="server" />
LinkButton:
The LinkButton and the ImageButton controls operate similarly to an ordinary Button
control.
presents itself as a simple <a> element but posts back (using JavaScript) instead of
requesting a new page.
Basic syntax:
<asp:LinkButton Text="Click me" OnClick="lblClick" runat="server" />
d Write a code that shows how to write a "LOCAL" cookie to a client's computer.
The "LOCAL" cookie, stores
FirstName
LastName
Answer: (step1- Interface/layout 2 marks + step2 - code 3 marks)
Step1:
Create the user layout to enter FirstName and LastName. i.e. WebForm
Step2: Code behind(.cs code)
WriteCookieButton_Click event handler in the code behind file has the code required
towrite the cookie to the client computer as shown below.
protected void WriteCookieButton_Click(object sender, EventArgs e)
{
// Create an instance of HttpCookie class
HttpCookie LocalCookie = new HttpCookie("LOCAL");
LocalCookie["FirstName"] = FirstNameTextBox.Text;
LocalCookie["LastName"] = LastNameTextBox.Text;
// Write the cookie to the client computer
Response.Cookies.Add(LocalCookie);
}
Following is optional
ReadCookieButton_Click event handler in the code behind may have code to read
the cookiefrom the client computer as shown below.
protected void ReadCookieButton_Click(object sender, EventArgs e)
{
// Check if the "LOCAL" cookie exists on the client computer
if (Request.Cookies["LOCAL"] != null)
{
//Retrieve the "LOCAL" cookie into a cookie object
HttpCookie LocalCookie = Request.Cookies["LOCAL"];
//Write FirstName,LastName and LastVisit values
Response.Write("First Name = " + LocalCookie["FirstName"] + "");
Response.Write("Last Name = " + LocalCookie["LastName"] + "");
}
}
4. Attempt any two of the following:
a Explain CustomValidator control with suitable example.
Answer: (explanation 1 mark + code example - 2 marks + properties 2 marks)
CustomValidator control
10
The CustomValidator control allows you to write a method to handle the validation of
the value entered.
If the other validator controls don’t fulfill the requirements of the validation, the
CustomValidator can be used. With the CustomValidator, both a client- and serverside validation function can be defined.
Double click on the CustomValidator control and add the following code:
protected void CustomValidator1:ServerValidate(object source,
ServerValidateEventArgs args)
{
string str = args.Value;
args.IsValid = false;
//checking for input length greater than 6 and less than 25 characters
if (str. Length < 7 II str. Length > 20)
{
return;
}
//checking for a atleast a single capital letter
bool capital = false;
foreach (char ch in str)
{
if (ch >= ‘A’ && ch <= ‘Z’)
{
capital true;
break;
}
}
if (!capital)
{
return;
}
bool digit = false;
foreach (char ch in str)
{
if (ch >= ‘0’ && ch <= ‘9’)
{
digit = true;
break;
}
if (!digit)
{
return;
}
args.IsValid = true;
}
}
Important properties:
Property
Explanation
ClientValidationFunction Specifies the name of the client-side validation script
function to be executed.
ControlToValidate
The id of the control to validate
ErrorMessage
The text to display in the ValidationSummary control
when validation fails.
id:
A unique id for the control
IsValid:
A Boolean value that indicates whether the control
specified by ControlToValidate is determined to be
valid
OnServerValidate
Specifies the name of the server-side validation script
function to be executed
Specifies that the control is a server control. Must be
set to "server"
runat
b What is the relationship between master page and content page?
Answer(explanation 1 mark each + syntax(tag) 1 ½ each)
Every Master Page should include at least one ContentPlaceHolder control; this is a
placeholder for the content from the content page.
<asp:ContentPlaceHolder id=”ContentPlaceHolder1” runat=”server”> </asp :
ContentPlaceHolder>
The content page is a standard aspx page in which MasterPageFile attribute should
be added to the page directive for binding the content page to the master page. The
content pages can not include the common tags as <Body>, <Head> etc. You can
design your content page just like any other aspx page by adding static text and
server controls.
<%@ Page Language = “C#” MasterPageFile = “.../master/MasterPage.master”
AutoEventWireup = “true” CodeFile=”Default2.aspx.cs” Inherits=”Default2”
Title=”Untitled Page” %>
Inside the content pages by default Content server control is get added. While
designing the, content page you have to add controls to the content server control For
example,
<asp: Content ID=”Content1” ContentPlaceHolderID=”ContentPlaceHolder1”
Runat=”Server”>
</asp : Content>
The attribute ContentPlaceHolderlD is very important as it decides what content will
be bound to which ContentPlaceHolder on the master page. It is way to decide the
location of where the contents will be displayed.
c Explain UrlEncode() and UrlDecode() methods in ASP.NET.
Answer:
We cannot send special characters through query string. All special characters should
be encoded when you pass them through the query string. The encoded string must
be decoded at the receiver.
There are two methods to achieve this- UrlEncode and UrlDecode():
The main purpose of these two methods is to encode and decode the urls
respectively. We need to encode the urls because some of the characters are not
safe sending those across browser. Some characters are being misunderstood by the
browser and that leads to data mismatch on the receiving end. Characters such as a
question mark (?), ampersand (&), slash mark (/), and spaces might be truncated or
corrupted by some browsers.
UrlEncode()
This method is used to encode a string to be passed through URL to a another web
page. URLencode replaces unsafe ASCII characters with a "%" followed by two
hexadecimal digits.
Syntax:
UrlEncode (string str )
UrlDecode()
This method is used to decode the encoded URL string. Decodes any %## encoding
in the given string.
Syntax:
UrlDecode (string str )
d Create a web page to read student’s seat number, name and contact number using
text boxes. Use appropriate validation controls to validate the following
Student roll number should be from 1 to 120, name is compulsory and contact
number must be of 10 digits. Write HTML and code behind code.
Answer:(Layout 2 marks+ Validation control properties 1 each)
Following controls are required to use
For seat number –
RangeValidator Control
Property
ControlToValidate
MinimumValue
MaximumValue
Error message
Value
txtSeatNo
1
120
Invalid seat no
For name –
RequiredFieldValidator Control
Property
Value
ControlToValidate
txtName
Error message
Name field is compulsory
For contact number –
RegularExpresionValidator Control
Property
Value
ControlToValidate
txtContactNo
ValidationExpression
\d{10}
Error message
Invalid contactnumber
5. Attempt any two of the following:
a What is DataReader? Explain ExecuteReader, ExecuteNonQuery methods.
Answer(explanation 1 mark+ExecureReader 2+ExecuteNonQuery 2)
DataReader:
DataReader is used to read the data from database and it is a read and forward only
connection oriented architecture during fetch the data from database. Generally we
will use ExecuteReader object to bind data to datareader.
1. ExecuteNonQuery: Executes commands that have no return values such
UPDATE or DELETE. It returns an integer that indicates the number of rows that
were affected.
Example:. int result=cmd.ExcecuteNonQuery();
2. ExecuteReader : Returns a result set by way of a DataReader object. It contains a
record in memory at any time. It is used to retrieve a read-only, forward-only stream
of data from database.
Example:
DataReader dr=null;
dr=cmd.ExecureReader();
b Explain command object in ADO.NET
Answer(explanation 1+properties and methods 2 each)
Command object:
The ADO Command object is used to execute a single query against a database. The
query can perform actions like creating, adding, retrieving, deleting or updating
records.
If the query is used to retrieve data, the data will be returned as a RecordSet object.
This means that the retrieved data can be manipulated by properties, collections,
methods, and events of the Recordset object.
10
c Consider there is a table named StudentsInfo having fields such as CodeNo,
Name, Address, ContactNo, City in Sql Server. Write code to display get all
record from database into GridView control.
Answer:
SqlConnection conn = new SqlConnection();
conn.ConnectionString = (@"Data Source=ADMIN-PC\SQLEXPRESS;Initial
Catalog=Database_Name;Integrated Security=True");
string query = "SELECT * FROM StudentsInfo ";
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(query, conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataSet myDS = new DataSet();
da.Fill(myDS,"Student");
GridView1.DataSource = myDS;
GridView1.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = "Problem in connection or in database";
}
finally
{
conn.Close();
}
d Explain windows authentication in ASP.NET.
Anser:
Windows authentication: The Windows authentication provider is the default
provider for ASP .NET. It authenticates the users based on the users Windows
accounts. Windows authentication in ASP.NET actually relies on IIS to do the
authentication. IIS be configured so that only users on a Windows domain can log in.
if a user attempts access a page and is not authenticated then user will be shown a
dialog box asking them to enter their username and password. This information is
then passed to the Web server and checked against the list of users in the domain. if
the user has supplied valid credentials access is granted.
To configure ASP.NET to use Windows authentication use the following code:
<system. web>
<authentication mode=”Windows”/>
<authorization>
<allow users”*”/>
</authorization>
</system.web>
<allow users=”*”/>
statement specifies permissions are provided to authorized users as well anonymous
users.
There are four different kinds of Windows authentication options available that
can
configured in IIS and they are given bellow:
• Anonymous Authentication: In this, IIS does not perform any authentication check
and allows access to any user to the ASP .NET application.
• Basic Authentication: In this, a Windows user name and password have to be
provided to connect. This information is sent over the network in plain text and
hence this is an insecure kind of authentication.
• Digest Authentication: It is almost same as Basic Authentication but the password
is hashed before it is sent across the network.
•Integrated Windows Authentication: In this, password is not sent across the
network and some protocols are used to authenticate users. It provides the tools
for authentication and strong cryptography is used to help to secure information
in systems across entire network.
6. Attempt any two of the following:
a What is Ajax? Explain UpdatePanel control with example.
Answer:
Answer:
1. The Update Panel control is a key component in creating flicker-free pages.
In its most basic application, you simply wrap the control around content you
want to update, add a ScriptManager to the page, and you’re done.
2. Whenever one of the controls within the UpdatePanel causes a postback to
the server, only the content within that UpdatePanel is refreshed.
Protected void Page Load(Obj ect sender,Eventargs e)
{
Label 1 .text=System.DateTime.Now.ToStringQ;
}
<asp:UpdatePanel 1D=”Updatepanel” runat=”server”>
10
<ContentTemplate>
<asp:TextBox ID=”Text1” runat= “server”></asp :TextBox>
<asp:TextBox ID=”Text2” runat= “server”></asp :TextBox>
<asp:Label ID=”Labell” runat= “server”></asp :Label>
<asp :Button ID=”Button1” runat “server” text=”Calculate” />
</ContentTemplate>
</asp :UpdatePanel>
<asp:Content ID=”Content2” ContentPlaceHolderlD=”cpMainContent”
runat=”Server”> <asp: S criptManager ID “ ScriptManagerl” runat “ server”>
</asp :ScriptManager> <asp:UpdatePanel ID”UpdatePanel 1” runat=”server”>
How It Works
1. By wrapping the content in an UpdatePanel you define a region in your page that
you want to refresh without affecting the entire page.
2. In the example, the Button control inside the UpdatePanel caused a postback and
thus a refresh ofjust the region the control is defined in. Rather than replacing the
entire page, only the part of the page that is wrapped in the UpdatePanel is refreshed,
causing a flicker-free reload of the page.
3. The UpdatePanel and its content is the only part of the page that is updated when
you click a button.This is the default behavior of an UpdatePanel, where only its inner
contents are refreshed by other server controls defined within the <Content
Template> element.
b What is the use of Document Ready function?
Document.Ready:
All You jQuery methods in our examples are inside a document ready event:
$(document).ready(function(){
// jQuery methods go here...
});
This is to prevent any jQuery code from running before the document is finished
loading (is ready).
It is good practice to wait for the document to be fully loaded and ready, before
working with it. This also allows you to have your JavaScript code before the body of
your document, in the head section.
Here are some examples of actions that can fail if methods are run before the
document is fully loaded:
Trying to hide an element that is not created yet
Trying to get the size of an image that is not loaded yet
Tip: The jQuery team has also created an even shorter method for the document
ready event:
$(function(){
// jQuery methods go here...
});
c Explain JQuery expression with example
d Create a web page to declare and initialize array of 10 integers and display the
numbers greater than 30 using LINQ. Code should execute on button's click
event in a web page.
Answer:
Button1_Click()
{
// Data source.
int[] numbers = { 90, 8,71, 82, 93, 75, 82 ,45,9,2};
// Query Expression.
IEnumerable<int> searchQuery =
//query variable
from numbers in numbers
//required
where score > 30
// optional
select numbers;
//must end with select or group
// Execute the query to produce the results
foreach (int n in searchQuery)
{
Console.WriteLine(n);
}
}
// Outputs: 90 71 82 93 75 45
7. Attempt any three of the following:
a What is post-back event? Explain IsPostBack with suitable example.
Answer(explanation 2 marks + example 3 marks)
If Page.IsPostBack property is false, the page is loaded at a first time.If it is true, the
page is posted back to the server i.e. loaded for the next time.
The Page_Load() event runs every time the page is loaded but if you want to execute
the code in the Page_Load event only once i.e. for the first time page is loaded then
you can use Page.IsPostBack property.
Example:
<HEAD runat=”server”>
<Script runat=”server”>
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Label1.Text=”Page is loaded first time”
}
else
{
Label1.Text=”Page is not loaded first time”
}
</Script>
</HEAD>
<BODY>
<Form id=”form1” runat=”server”>
<asp:Label id=”Label1” runat=”server” Text=” ”/>
<asp :Button id=”Button1” runat “server” Text=”Submit” />
</Form>
</BODY>
b Write a code to achieve overriding using virtual method. Use comments whenever
necessary.
15
Answer:
class Base //base class
{
public virtual void Display()
//virtual method in base class
{
System.Console.WriteLine("Display - Base");
}
}
class Derived : Base
{
public override void Display()
//derived class base class Display() is overridden
here
{
System.Console.WriteLine("Display - Derived ");
}
}
class Demo
{
public static void Main()
{
Base b;
b = new Base ();
b.Display();
b = new Derived ();
b.Display();
}
}
Output
Display - Base
Display - Derived
c Explain the Provider Model of ASP .NET.
Answer:(explanation 3 marks + diagram 2 marks)
With the provider model the system is flexible to able to use any class that extends a
particular base class. Users can create their own derived classes that include some
custom logic and business rules. The new class can be flawlessly plugged into the
system without troubling existing code of the application. Provider model provides
clean separation between the code and the backend implementation.
A provider is software that provides a standardized interface between a service and a
data source. ASP.NET providers are as follows:
1. Membership
2. Role management
3. Site map
4. Profile
5. Session state etc.
d Write short note on jQuery event functions.
Answer:(syntax and explanation 3marks+JQuery method 2 marks)
jQuery Event Methods/functions:
Event methods trigger, or bind a function to an event for all matching elements.
Trigger example:
$("button").click() - triggers the click event for a button element.
Binding example:
$("button").click(function(){$("img").hide()}) - binds a function to the click event.
All the different visitor's actions that a web page can respond to are called events.
Event methods trigger or attach a function to an event handler for the selected
elements.
The following table lists all the jQuery methods used to handle events.
bind() Attaches event handlers to elements
blur() Attaches/Triggers the blur event
change()
Attaches/Triggers the change event
click() Attaches/Triggers the click event
dblclick()
Attaches/Triggers the double click event
focus()
Attaches/Triggers the focus event
hover()
Attaches two event handlers to the hover event
keydown() Attaches/Triggers the keydown event
keypress() Attaches/Triggers the keypress event
keyup()
Attaches/Triggers the keyup event
mousemove()
Attaches/Triggers the mousemove event
mouseout() Attaches/Triggers the mouseout event
mouseover() Attaches/Triggers the mouseover event
mouseup() Attaches/Triggers the mouseup event
ready()
Specifies a function to execute when the DOM is fully loaded
unload()
Deprecated in version 1.8. Attaches an event handler to the unload
event
e Differentiate between DataSet and DataReader.
Answer:
DataSet
DataReader
The DataSet class in ADO.Net operates
DataReader is a connection oriented
in an entirely disconnected nature.
service.
DataSet is an in-memory representation
of a collection of Database objects
including related tables, constraints, and
relationships among the tables.
It fetches entire table or tables at a time
so greater network cost.
DataSet is not read-only so we can do
any transaction on them.
DataAdapter is used to get data in
DataSet
DataReader is designed to retrieve a
read-only, forward-only stream of data
from data sources.
It fetches one row at a time so very
less network cos.
DataReader is readonly so we can't do
any transaction on them.
DataAdapter is not required
Dataset works with the help of xml
technology
Example:
Dataset ds=new Dataset ( );
DataReader doesn’t provide this
feature.
Example:
Sqlcommand cmd =new sqlcommand
(select * from emptable);
DataAdapter1Fill(ds,”newtablename”) //
where newtablename is table alias name
Data Reader dr= cmd.ExecuteReader (
in dataset
)
f What are different ways to integrate a CSS into a web page?
Answer:
(i)
Inline stylesheet:
Style specifications are placed directly inside an HTML element in the
code. Inline Styles cannot be reused at all.
Example of an Inline Style:
<p style="font-size: 14px; color: purple;"></p>
The style is embedded inside the HTML element using the style attribute. The
above style cannot be reused at all. It will only target that one paragraph.
(ii)
Embedded stylesheet(Internal stylesheet):
In this type style specifications are placed within the head section of the web
page inside style tag. Internal Styles are placed inside the head section of a
particular web page via the style tag.

Internal Styles are placed inside the <head> section of a particular web page
via the style tag.
<style type="text/css"></style>


These Styles can be used only for the web page in which they are embedded.
Therefore, you would need to create these styles over and over again for each
web page you wish to style.
When using the style builder in Expression Web, Define the style in the
Current Page. This will create an Internal Style.
Advanced Use of Internal Styles unless you need to override an External
Style.


Example Embedded stylesheet:
<html>
<head>
<title>Learning HTML</title>
<style type="text/css"></>
p { color: blue; }
.importantstuff { font-size: 20px; }
#lookhere { font-size: 28px; text-align: center; color: green; }
</style>
</head>
<body>
<p>Woo hoo! I'm learning HTML!</p>
<p class="importantstuff">Woo hoo! I'm learning HTML!</p>
<p class="importantstuff" id="lookhere">Woo hoo! I'm learning HTML!</p>
<p class="importantstuff">Woo hoo! I'm learning HTML!</p>
</body>
</html>
(iii)
External style sheet:
External CSS is a that contains only css code and it is saved with .css extension.
This css file is then referenced in your HTML using the <LINK> .tag in header
section of a page.
The scope of external css is an entire page.
Syntax/example:
<head>
<link rel="stylesheet" type="text/css" href="mystylesheet.css">
</head>