demo-variableglobal.aspx
来自「asp.net1.1入门经典C#.2003」· ASPX 代码 · 共 42 行
ASPX
42 行
<%@ Page Language="C#" Debug="true" %>
<script runat="server">
string strVariableGlobal = "Use me anyplace on the page";
void Page_Load()
{
string strMyVariable1 = "Block Variable Used In Block";
if (1==1)
{
string strMyVariable2 = "Block Variable Used In Block";
string strMyVariable3 = "Block Variable Used After Block";
lblMessageBlockInBlock.Text = strVariableGlobal;
} //End IF(1==1)
lblMessageProcedure.Text = strVariableGlobal;
SubProcedure2();
} //End Page_Load
void SubProcedure2()
{
lblMessageBlockOutBlock.Text = strVariableGlobal;
} // end SubProcedure2()
</script>
<html>
<head>
<title>Variable Scope</title>
</head>
<body>
<form runat="server">
<asp:Label id="lblMessageBlockInBlock" runat="server" text="DEFAULT - BlockInBlock"/>
<br />
<asp:Label id="lblMessageBlockOutBlock" runat="server" text="DEFAULT - BlockOutBlock"></asp:Label>
<br />
<asp:Label id="lblMessageProcedure" runat="server" text="DEFAULT - Procedure"></asp:Label>
<br />
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?