Same way, except for the syntax change in C#:

<%@ Page language="C#"%>
<script runat="server">

public void Page_Load(object sender, EventArgs e)
{
    Session["ABC"] = "19278";
}

</script>
<html>
<head>
</head>
<body>
Session value is : <% = Session["ABC"] %>
</body>
</html>

NOTE: This is an ugly way to do it.  A more elegant solution would be to
use a .NET Server control:

<%@ Page language="C#"%>
<script runat="server">

public void Page_Load(object sender, EventArgs e)
{
    // assume this is not hard-coded, but loaded from
    // other code
    Session["ABC"] = "19278";

    // now put the session value on the page    
    SessValue.Text = Session["ABC"].ToString();
}

</script>
<html>
<head>
</head>
<body>
Session value is : <asp:Label id="SessValue" runat="server"></asp:Label>
</body>
</html>

---
Patrick Steele ([EMAIL PROTECTED])
Lead Software Architect
Image Process Design



-----Original Message-----
From: Ryan Jameson (USA) [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, September 10, 2002 6:24 PM
To: dotnet
Subject: Sessions


in old school asp vb I could do this Session("MyVar") = "hi"

how do I do it now in .NET using C# as the language?

Thanks.
<>< Ryan

---
You are currently subscribed to dotnet as: [EMAIL PROTECTED]
To unsubscribe send a blank email to
%%email.unsub%%

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/



---
You are currently subscribed to dotnet as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

---------
Administrated by 15 Seconds : http://www.15Seconds.com
List Archives/Search : http://local.15Seconds.com/search
Subscription Information : http://www.15seconds.com/listserv.htm
Advertising Information: http://www.internet.com/mediakit/


Reply via email to