[英]How can I output variable from C# class to aspx file (asp.net)
I'm unable to output variable from code behind to aspx file. 我无法将变量从代码后面输出到aspx文件。 Please help me out, I'll be thankful.
请帮帮我,我会很感激。 Here is code of aspx.cs and aspx files:
这是aspx.cs和aspx文件的代码:
protected void Page_Load(object sender, EventArgs e)
{
String Marks = (String) (Session["Marks"]);
}
Here is code of aspx file: 这是aspx文件的代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1> <%=Marks%> </h1>
</div>
</form>
</body>
</html>
使用以下代码段
<h1><% =Session["Marks"]%></h1>
You can't access variables from the code behind. 您不能从后面的代码访问变量。 However you can access session in aspx page.
但是,您可以在aspx页面中访问会话。 So use
Session["Marks"]
因此,请使用
Session["Marks"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.