Stick to Learning asp.net--(10)
Last Update:2017-02-28
Source: Internet
Author: User
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 ()