Bkjia.com Network ProgrammingThe Application object is an instance of the HttpApplicationState class. It can generate a variable that can be accessed by all Web applications. The accessible scope of this variable covers all users, that is to say, all programs that are using this webpage can access this variable.
Create a website with two web pages. The Code is as follows:
1. Index. aspx code:
Reference content is as follows: <% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "Index. aspx. cs" Inherits = "Index" %> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <Html xmlns = "http://www.w3.org/1999/xhtml"> <Head runat = "server"> <Title> Example Teaching: ASP. NET built-in object Application_bkjia.com </title> </Head> <Body> <Form id = "form1" runat = "server"> <Div> <Table style = "width: 300px; height: 100px"> <Tr> <Td style = "width: 100px"> Username: </td> <Td style = "width: 246px"> <Asp: TextBox ID = "TextBox1" runat = "server"> </asp: TextBox> </td> </Tr> <Tr> <Td style = "width: 100px"> Password & nbsp; Code: </td> <Td style = "width: 246px"> <Asp: TextBox ID = "TextBox2" runat = "server" TextMode = "Password"> </asp: TextBox> </td> </Tr> <Tr> <Td style = "text-align: center;" colspan = "2"> <Asp: Button ID = "Button1" runat = "server" Text = "login" OnClick = "button#click"/> </td> </Tr> </Table> </Div> </Form> </Body> </Html> Index. aspx. cs code: Using System; Using System. Data; Using System. Configuration; Using System. Collections; Using System. Web; Using System. Web. Security; Using System. Web. UI; Using System. Web. UI. WebControls; Using System. Web. UI. WebControls. WebParts; Using System. Web. UI. HtmlControls; Public partial class Index: System. Web. UI. Page { String strInfo; Protected void Page_Load (object sender, EventArgs e) { } Protected void button#click (object sender, EventArgs e) { Application ["Info"] = TextBox1.Text; StrInfo = Application ["Info"]. ToString (); If (TextBox1.Text = "admin" & TextBox2.Text = "admin ") { Session ["name"] = TextBox1.Text; Response. Redirect ("Default. aspx? Info = "+ strInfo +" "); // the value in the address bar } } } |
- 2 pages in total:
- Previous Page
- 1
- 2
- Next Page