⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tio-variablescope2fixed.aspx

📁 asp.net1.1入门经典C#.2003
💻 ASPX
字号:
<%@ 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";
        string strMyBlockVariableUsedOutside= "Block Variable Used After Block";
        lblMessageBlockInBlock.Text = strMyBlockVariableUsedInside;
        lblMessageFunction.Text = strMyFuncVariable;
        lblMessageBlockOutBlock.Text = strMyBlockVariableUsedOutside;
      }   // end if(postback)
          // note - block variables now out of scope
    
    }   // End page_load

</script>
<html>
<head>
    <title>Variable Scope</title>
</head>
<body>
    <form runat="server">
        <asp:Label id="lblMessageBlockInBlock" runat="server" text="DEFAULT -&#13;&#10;     BlockInBlock"></asp:Label>
        <br />
        <asp:Label id="lblMessageBlockOutBlock" runat="server" text="DEFAULT -&#13;&#10;     BlockOutBlock - Fixed "></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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -