Built in Objects ASP
Built in Objects ASP
Qadri Hamarsheh
ASP.NET Objects
Introduction
• Using ASP.NET built-in objects, you can access to information regarding the Web
server, the client who is accessing a Web page, the Web application that contains the
Web page, and the fields in the HTTP request and response streams.
• The Request, Response, Server, Application, and Session objects are part
of ASP.NET and are used in much the same way as they are in ASP. However, in
ASP.NET these objects are defined in new classes in the System.Web namespace.
Object Description
Application Describes the methods, properties, and collections of the object that
stores information related to the entire Web application, including
variables and objects that exist for the lifetime of the application.
Request Describes the methods, properties, and collections of the object that
stores information related to the HTTP request. This includes forms,
cookies, etc.
Response Describes the methods, properties, and collections of the object that
stores information related to the server's response. This includes
displaying content, manipulating headers, etc.
Server Describes the methods and properties of the object that provides
methods for various server tasks. With these methods you can execute
Page 1 of 5 1
ASP.NET Dr.Qadri Hamarsheh
ASP.NET Objects
code, get error conditions, encode text strings, create objects for use by
the Web page, and map physical paths.
Session Describes the methods, properties, and collections of the object that
stores information related to the user's session, including variables and
objects that exist for the lifetime of the session.
Response object
Response.Write Method
Examples:
Example 1 (string)
<%
Response.Write "Hello World"
%>
Output:
Hello World
Example 2.a (string with HTML Tags)
<%
Response.Write("Hello<br/>World")
%>
Output:
Hello
World
Example 2.a (string with HTML Tags)
<% Response.Write "<TABLE WIDTH = 100%\>" %>
Example 3 (variables and concatenation operators)
Int myNum = 25;
String myString = "Hello";
Response.Write("myNum = " + myNum + "<br />");
Response.Write("myString = " + myString +
this.TextBox1.Text + "<br />");
Page 2 of 5 2
ASP.NET Dr.Qadri Hamarsheh
ASP.NET Objects
ASP.NET Objects
Programming Example
Example 19-
19-1
<script language="C#"
language="C#" runat="server">
runat="server">
private class Accounts
{
long LUserID;
string SEmail,SFirst,SLast;
bool Bstatus;
public Accounts ( long id, string em, string f, string l, bool s)
{
LUserID= id; SEmail = em; SFirst = f;
SLast = l; Bstatus = s; }
public long UserID
{ get { return LUserID; } }
public string Email
{ get { return SEmail; } }
public string First
{ get { return SFirst; } }
public string Last
{ get { return SLast; } }
public bool Status
{ get { return Bstatus; } }
}
private void Page_Load ( object sender, EventArgs e)
{
ArrayList AccountList = new ArrayList ();
if (!IsPostBack)
{
AccountList.Add(new
AccountList.Add(new Accounts (1,"[email protected]"
(1,"[email protected]",
"[email protected]","Sami",
"Sami","Issa",
"Issa",true));
true));
AccountList.Add(new
AccountList.Add(new Accounts (2,"[email protected]"
(2,"[email protected]",
"[email protected]","Naji",
"Naji","Ali",
"Ali",false));
false));
AccountList.Add(new
AccountList.Add(new Accounts (3,"[email protected]"
(3,"[email protected]",
"[email protected]","Najeeb",
"Najeeb","Issa",
"Issa",true));
true));
AccountList.Add(new
AccountList.Add(new Accounts (4,"[email protected]"
(4,"[email protected]",
"[email protected]","Fadi",
"Fadi","Fawzi",
"Fawzi",true
true));
Page 4 of 5 4
ASP.NET Dr.Qadri Hamarsheh
ASP.NET Objects
Page 5 of 5 5