📄 tio-variablescope2fixed.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 - BlockInBlock"></asp:Label>
<br />
<asp:Label id="lblMessageBlockOutBlock" runat="server" text="DEFAULT - 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 + -