Stick to Learning asp.net--(10)

Source: Internet
Author: User
Tags xmlns
asp.net one, namespace

is only a symbol of the image, can be a rough expression of the type of case.

The following lists the most commonly used namespaces when creating Web programs using asp.net:

system.web; System.Web.Ui; System.IO; System.Collections; System.Diagnostics; System.date; System.Globalization; System.Drawing; System.Xml

Use of Response.Redirect:



<script language= "C #" runat= "Server" >

void Page_Load (Object Source,eventargs e) {

if (!) ( IsPostBack)) {

Button1.text= "OK";
DROPDOWNLIST1.ITEMS.ADD ("http://www.sohu.com");
DROPDOWNLIST1.ITEMS.ADD ("http://www.sina.com.cn");
DROPDOWNLIST1.ITEMS.ADD ("http://www.163.com");

}

}
public void Click (Object O,eventargs e) {

Response.Redirect (DropDownList1.SelectedItem.Text);

}
</script>


<form runat= "Server" >
<asp:dropdownlist id= "DropDownList1" runat= "Server" ></asp:DropDownList>
<asp:button id= "Button1" runat= "Server" onclick= "click" text= ""/>
</form>



Ii. Core objects of asp.net

1. Request object:

Partial properties:

Applicationpath

Path

Physicalapplicationpath

Browser

Cookies

IsSecureConnection

RequestType

QueryString

Url

Rawurl

Userhostname

UserHostAddress

UserLanguages

Here is a small example of checking these properties:

<%@ Page language= "C #" contenttype= "text/html" responseencoding= "gb2312"%>

<script language= "C #" runat= "Server" >
void Page_Load (Object Src, EventArgs E)
{
if (! IsPostBack) {
if (request.browser.browser== "IE")
{
if (request.browser.majorversion<6) {
label1.text= "Time to update your ietnet Explore!";
}
else{
Label1.text= "The boy is very hanging ah, already used the newest browser!";
}
}
Else
{
label1.text= "Your Browser is" +request.browser.browser+ "!";
}
}
}
</script>

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Untitled Document </title>
<body>

<asp:label id= "Label1" runat= "Server" text= ""/>

</body>



2, Response object

Some of the following properties and methods:

Buffer

ContentType

Cookies

Clear ()

Flush ()

End ()

Redirect ()

Write ()

WriteFile ()

Here is an example of an image:

<%@ Page language= "C #" contenttype= "text/html" responseencoding= "gb2312"%>
<title> Untitled Document </title>
<body>
<%
for (int i=0;i<50000;i++) {
Response.Write ("X");
if (i%300==0)
Response.Write ("<br>");
}
%>
</body>

<%@ Page language= "C #" contenttype= "text/html" responseencoding= "gb2312"%>
<title> Untitled Document </title>
<body>
<%
Response.buffer=false;
for (int i=0;i<50000;i++) {
Response.Write ("X");
if (i%300==0)
Response.Write ("<br>");
}
%>
</body>

These two pieces of code are very imaginative, but the operating difference is very obvious.

3. Server Objects

MachineName

ScriptTimeout

HtmlEncode ()

HtmlDecode ()

MapPath ()

UrlEncode ()

UrlDecode ()




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.