Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 4

Homework Title / No.

: 3rd___________________Course Code :cse-301________

Course Instructor : _Mr.Parmjeet Singh Course Tutor (if applicable) : ____________

Date of Allotment : __________ Date of submission : 9/11/2010__________

Student’s Roll No. _A14_______ Section No. : __B2804___________


Declaration:
I declare that this assignment is my individual work. I have not copied from any other
student’s work or from any other source except where due acknowledgment is made
explicitly in the text, nor has any part been written for me by another person.
Student’s Signature :
Jagdeep Kaur
Evaluator’s comments:
_____________________________________________________________________
Marks obtained : ___________ out of ______________________
Content of Homework should start from this page only:

PART A

Q1. Suppose you have been given a task of working with cascading style sheet backgrounds.
What you need to do is to set the background color of different elements and to repeat a
background image only horizontally. Write the code snippet for the same.

Ans. 1
<html>
<head>
<style type="text/css">
h1
{
background-color:white;
}
p
{
background-color: green;
}

body
{
background-image:url('C:\Users\santymeghs\Desktop/images.jpg');
background-repeat:repeat-x;
}
</style>
</head>
<body>
<h1>background: color white</h1></br>
<p>This paragraph has it's own background color green.</p>
</body>
</html>

Q2. When you are working with an application on your computer, you open it, do some
changes and then you close it. 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 that is
why the changes made by you are not consistent at all. So you suggest a solution in such a
way that computer start knowing who you are, and it knows when you open the application
and you close the application. Write a program in ASP to implement your proposed solution
practically.

Ans. 2 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.
<%
Dim x, y
For Each x in Request.Cookies
Response.Write("<p>")
If Request.Cookies(x).HasKeys Then
For Each y in Request.Cookies(x)
Response.Write(x & ":" & y & "=" & Request.Cookies(x)(y))
Response.Write("<br />")
Next
Else
Response.Write(x & "=" & Request.Cookies(x) & "<br />")
End If
Response.Write "</p>"
Next
%>

Q3. Is it possible to create objects with session or application scope in Global.asa by using the
<object> tag? If yes, then give an example of creating object of session scope in support of
your answer.
Ans. 3
It is possible to create objects with session or application scope in Global.asa by using the
<object> tag.

For session:-

<object runat="server" scope="session" id="megha" progid="MSWC.AdRotator">


</object>

example creates an object of session scope named "megha" by using the ProgID parameter.

For application:-
<object runat="server" scope="application" id="MyConnection"
classid="Clsid:8AD3067A-B3FC-11CF-A560-00A0C9081C21">
</object>

example creates an object of application scope named "MyConnection" by using the ClassID
parameter.

PART B

Q4. Write a code snippet in ASP to send query information when a user clicks on a link to
another page. Retrieve that information on the destination page using the concept of
QueryString.

Ans:-
<html>
<body>
<a href=“simple.asp?color=pink”>
Example<a/>
<%
Response.write(Request.QueryString)
%>
</body>
</html>

Q5. Discuss the common way to access the database from an ASP page.
Ans:-
We have researched the Internet and have come up with a great list of
ASP Database Tutorials that you might find useful. The next time that
you are having a problem with your SQL database when developing an
ASP application, come back to this page to solve your problem.
ASP Web Pro – OPEN DATABASE CONNECTION
The most basic purpose of ASP is to allow a website to connect to a
database and show “Live data”. It is called live data because ideally
the database administrator will be updating the database routinely
which will therefore automatically update the website.
Bullschmidt – ASP Web Database Sample - A sample Web
database can give you ideas about tying everything together and can
even be used as a starting point for a Web project. Login and add, edit,
or view fictional customers and invoices!
Database Simplicity With Class
This database class handles Select, Insert, Update, and Delete. It also
takes steps to ensure your SQL syntax is valid, and that memory
leaks / errors are prevented. Tutorial comes with demo, downloadable
code, and an in depth explanation.
ASP Speed Tricks - This article describes practical methods of
optimizing the performance of ASP pages which retrieve and display
tabular data from a database. Test results of each coding technique
show the potential for dramatic speedups of dynamic web pages.
Optimized Heirarchical Table Printing in ASP - An common task of
ASP pages is to display heirarchical reports or tables. This section
generalizes one aspect of the problem and then provides techniques
for increasing performance.

Q6. In addition to setting a style for a HTML element, CSS allows you to specify
your own selectors for a single, unique element as well as for a group of elements.
Write the code snippet for both types of selectors taking the text-align and color
attributes into account to give it a practical implementation.

Ans. 6
<html>
<head>
<style type="text/css">
#para1 /* id created*/
{
text-align:center;
color:red;
}
.center /*class created*/
{
text-align:center;
color: pink;
}
</style>
</head>

<body>
<h1 id="para1">use of id</h1> /*id called*/
<p class="center">use of class</p> /* class called*/
<h3 class="center">Center-aligned paragraph.</h3>
</body>
</html>

You might also like