asp.net页面的加载顺序
页面加载顺序如下:
Page.Init
Page.Load
Textbox.TextChanged
Button.Click
Page.PreRender
Page.Unload
在Page.Unload之前,页面就呈现出来了.
page.init只是在页面第一次载入的时候执行,当页面postback后从page.load开始执行.
e.g
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication8._Default" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lbl" runat="server"></asp:Label>
<br />
<asp:Button ID="btn" runat="server" onclick="btn_Click" />
</div>
</form>
</body>
</html>
C#代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication8
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
lbl.Text += "pageload is on.<br />";
else
lbl.Text += "This is not your first.<br />";
}
protected void Page_Init(object sender, EventArgs e)
{
lbl.Text += "pageinit is on.<br />";
}
protected void Page_PreRender(object sender, EventArgs e)
{
lbl.Text += "pageprerender is on.<br />";
}
protected void btn_Click(object sender, EventArgs e)
{
lbl.Text += "button i
相关文档:
代码如下:
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string s = "Browser Capabilities\n"
"Type = " + browser.Type ;
"Name = " + browser.Browser ;
"Version = " + browser.Version ;
"Major Version = " + browser.Ma ......
ASP.NET获取客户端IP/用户名等信息
1. 在ASP.NET中专用属性:
获取服务器电脑名:Page.Server.ManchineName
获取用户信息:Page.User
获取客户端电脑名:Page.Request.UserHostName
获取客户端电脑IP:Page.Request.UserHostAddress
2. 在网络编程中的通用方法:
获取当前电脑名:static System. ......
IIS 7 默认文件上传大小时30M
要突破这个限制:
1. 修改IIS的applicationhost.config
打开 %windir%\system32\inetsrv\config\applicationhost.config
找到: <requestFiltering>节点,
这个节点默认没有 <requestLimits maxAllowedContentLength="上传 ......
using System;
using System.Data;
using System.Configuration;
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;
using System.IO;
using System.Xml;
using System.Text; ......
asp.net遍历HashTable需要用到DictionaryEntry Object,asp.net遍历HashTable,可以通过如下两种方法来实现,
方法一:
foreach (System.Collections.DictionaryEntry objDE in objHasTab)
{
Console.WriteLine(objDE.Key.ToString());
Console.WriteLine(objDE.Value.ToString ......