Reputation: 981
I have a Default2.cs file which stores a value in session
TextBox1.Text = "Haii";
Session["name"] = TextBox1.Text;
and i need to retrieve it in an html page- Default.aspx
<script runat="server">
Sub Page_Load
string na=(string)Session["name"];
Label1.Text=na;
End Sub
</script>
it shows an error 'String' is a class type and cannot be used as an expression. please help
Upvotes: 0
Views: 186
Reputation: 9458
For ASPX Engine:
Enclose your code in <% Your Code here %>
<% string na=(string)Session["name"]; %>
For Razor Engine:
Enclose your code in @{ Your Code here }
@{
string na=(string)Session["name"];
}
Upvotes: 0
Reputation: 1892
Try this in HTML in Defaul.aspx,
<% string na=(string)Session["name"]; %>
<label id="Label1"><% =na %></label>
Upvotes: 1