fippif
asked on
define variables in .aspx.cs and use in .aspx
I have defined a string variable in .aspx.cs file, and I want to use that variable in the .aspx file.
In .aspx.cs file I have:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string Test = "------ test -------";
}
In .aspx file I have:
<%@ Page language="c#" Codebehind="WebForm7.aspx. cs" AutoEventWireup="false" Inherits="FileEditor2.WebF orm7" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm7</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScri pt" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout ">
<form id="Form1" method="post" runat="server">
<%=Test%>
</form>
</body>
</HTML>
In .aspx.cs file I have:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string Test = "------ test -------";
}
In .aspx file I have:
<%@ Page language="c#" Codebehind="WebForm7.aspx.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm7</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScri
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout
<form id="Form1" method="post" runat="server">
<%=Test%>
</form>
</body>
</HTML>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.