`
阅读更多
CompilationMode属性
禁止动态编译

事件引发序列
1) PreInit
2) Init
3) InitComplete
4) PreLoad
5) Load
6) LoadComplete
7) PreRender
8) PreRenderComplete
9)SaveStateComplete
10)UnLoad

Page.IsPostBack
检测页面是否已经回传给服务器

页面调试:
<%@ Page language="C#" Debug="true" %>

Web.Config
<configuration>
  <system.web>
    <compilation debug="true"/>
  </system.web>
</configuration>
----------------------------------------
<configuration>
  <system.web>
    <compilation debug="true"/>
    <customErrors mode="off"/>
  </system.web>
</configuration>

再添加
<deployment retail="true"/>禁止调试

<trace enabled="true"/>

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    private List<string> groceries = new List<string>();

    protected void Page_Load(object sender, EventArgs e)
    {
        groceries.Add("Milk");
        groceries.Add("Steak");
        groceries.Add("Fish");       
    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        bltGroceries.DataSource = groceries;
        bltGroceries.DataBind();
    }

    protected void Sort_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName == "Sort")
        {
            switch (e.CommandArgument.ToString())
            {
                case "ASC":
                    groceries.Sort(SortASC);
                    break;
                case "DESC":
                    groceries.Sort(SortDESC);
                    break;
            }
           
        }
    }

    int SortASC(string x, string y)
    {
        return String.Compare(x, y);
    }
    int SortDESC(string x, string y)
    {
        return String.Compare(x, y)*-1;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:Button ID="btnSortAsc" runat="server" Text="Sort ASC"
            CommandArgument="ASC" CommandName="Sort" oncommand="Sort_Command" />
   
      
        <asp:Button ID="btnSortDESC" runat="server" Text="Sort DESC"
            CommandArgument="DESC" CommandName="Sort" oncommand="Sort_Command" />
     <br />
        <br />
        <asp:BulletedList ID="bltGroceries" runat="server">
        </asp:BulletedList>
        <br />
   
    </div>
    </form>
</body>
</html>


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics