0

I'm unable to output variable from code behind to aspx file. Please help me out, I'll be thankful. Here is code of aspx.cs and aspx files:

protected void Page_Load(object sender, EventArgs e)
{
    String Marks = (String) (Session["Marks"]);                
}

Here is code of aspx file:

<!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>
1

2 Answers 2

2

Use following code snippet

<h1><% =Session["Marks"]%></h1> 
Sign up to request clarification or add additional context in comments.

Comments

1

You can't access variables from the code behind. However you can access session in aspx page. So use Session["Marks"]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.