tio-variablescope1.aspx

来自「asp.net1.1入门经典C#.2003」· ASPX 代码 · 共 31 行

ASPX
31
字号
<%@ Page Language="C#" Debug="true" %>
<script runat="server">

    void Page_Load()
    {
      string strMyFuncVariable = "Function-Level Variable";
      if(Page.IsPostBack)
      {
          string strMyBlockVariableUsedInside = "Block Variable Used In Block";
          lblMessageBlockInBlock.Text = strMyBlockVariableUsedInside;
          lblMessageFunction.Text = strMyFuncVariable;
      }   //end if pagepostback
    
    }   //end pageload

</script>
<html>
<head>
    <title>Variable Scope</title>
</head>
<body>
    <form runat="server">
        <asp:Label id="lblMessageBlockInBlock" runat="server" text="DEFAULT - BlockInBlock"></asp:Label>
        <br />
        <asp:Label id="lblMessageFunction" runat="server" text="DEFAULT - Function"></asp:Label>
        <br />
        <asp:Button id="Button1" runat="server" Text="Submit"></asp:Button>
    </form>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?