<%@ 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;
}
}
</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>
|