session creation in asp.net

i want to creat a session in asp.net

Page 1 of 1

3 Replies - 8617 Views - Last Post: 07 November 2008 - 04:37 AM Rate Topic: -----

#1 tejapasupuleti  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-November 08

session creation in asp.net

Post icon  Posted 05 November 2008 - 11:10 PM

[description]session creation in asp.net[/description]
Is This A Good Question/Topic? 0
  • +

Replies To: session creation in asp.net

#2 tejapasupuleti  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 05-November 08

Re: session creation in asp.net

Posted 05 November 2008 - 11:17 PM

View Posttejapasupuleti, on 5 Nov, 2008 - 10:10 PM, said:

[description]session creation in asp.net[/description]

it is very easy to create
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: session creation in asp.net

Posted 05 November 2008 - 11:29 PM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#4 phani1237  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 07-November 08

Re: session creation in asp.net

Posted 07 November 2008 - 04:37 AM

1.Define an ASP.NET web site.
2. Create two pages within the site. The first page will contain an ASP.NET Web Form that will post back to itself and then redirect to the second page.

Note: The reason this example uses two pages is to prove that a session variable is available to a second, third, fourth, etc. page in the web site. Request variables, which are an alternative to session variables, cannot be carried over from an ASP.NET Web Form on one page to a second page
3. The first page must contain an ASP.NET Web Form that contains one <asp:textbox> server control and an <asp:button> server control. The "id" attribute of the textbox control should be set to "txtFirstName". The full code for the first page is provided below. Choose either C# or VB, depending on which language you've chosen for your ASP.NET site:

This code pulls the contents from the <asp:textbox> server control named "txtFirstName" and creates a session variable named"sessFirstName" which is set equal to the contents of the server control. In other words, this code creates a session variable that holds the information the user enters on the form page.



In the first Page

<%@ Page Language="C#" %><script language="C#" runat="server">
   void Button1_Click(object sender, EventArgs e)
   {
   Session["sessFirstName"] = Request["txtFirstName"];
   Response.Redirect("session2.aspx");
   }</script><html><head><title>Session Page 1</title></head><body>
   ASP.NET C# session variable and web form example - page 1<form id="Form1" method="post" runat="server"><p>first name:<asp:TextBox id="txtFirstName" runat="server" /></p><p><asp:Button id="Button1" runat="server" Text="Submit" onclick="Button1_Click" /></p></form></body></html>


In the second page

<%@ Page Language="C#" %><html><head><title>Session Page 2</title></head><body><p>ASP.NET C# session variable and web form example - page 2</p><p>first name: <%=Session["sessFirstName"]%></p></body></html>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1