You must Sign In to post a response.

how to use session in C# Windows Application

hi Friends,
Pls reply the method of Session maintenence in C# Windows Application. If u have any examples pls fwd its very useful for me.
Regards,
Karthick.


Comments

Author: Satish Kumar J19 Sep 2007 Member Level: Gold   Points : 2

we dont have Session object in Window application

if want to you can use global variable please check below link for example.
http://www.thescripts.com/forum/thread486343.html

Regards,
Satish.

Author: Brainstorming Guy19 Sep 2007 Member Level: Gold   Points : 2

Hi,
You can't work with session in windows application. If you want to persist some value, you can use the cache. You can download and install the Microsoft Enterprise Library and make use of Cache.

Regards,
Brainstorming Guy aka Venkatarajan A

Author: keerthi J M19 Sep 2007 Member Level: Bronze   Points : 2

You can use static class to hold the the values of the variables temproverly upto closing the application.
It violets the OOPs consept but you can use it,
take a new class to your application ,Declare the variables as static as shown below,

 
using System;
using System.Collections.Generic;
using System.Text;

namespace DvmsProject
{
class clsStaticApplication
{
/

//User Name

public static string strUserName;
public static string UserName
{
get
{
return strUserName;
}
set
{
strUserName = value;
}
}
//Pass Word
public static string strPassword;
public static string Password
{
get
{
return strPassword;
}
set
{
strPassword = value;
}
}


}
}

you are taken user name in a text box in the first form,
assign text value to the static class variables ,
ex,
 
clsStaticApplication.UserName=TextBox1.Text.ToString();

Remember that for a static class no need to create an object ,you can use these variables directly using classname with properties,

Then you can get the values of the textbox in the others pages using the static variables
 
string UserName=clsStaticApplication.UserName;


If any douts regarding these let me know ,


Author: Karthick20 Sep 2007 Member Level: Gold   Points : 2

How to get value from session in another form?