473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to maintain session variable after refresh hit??

hi
i'm having one application in that i'm using one session variable.
my code works fine till the user hits refresh button but
after this session variable becomes empty.

below is the code i'm using

string RenderedOutput = string.Empty;
public static int Index = 0;
DataTable dt = new DataTable();
DataRow dr;
DataView dv;

protected void Page_Load(object sender, EventArgs e)
{
ClientScriptManager scriptMgr = Page.ClientScript;
String ContextID = "__gv" + GridView1.ID.ToString() + "__div";
String cbReference = scriptMgr.GetCallbackEventReference(this, "arg", "ReceiveServerData", ContextID);
String callbackScript = "function CallServer(arg,context) {"+ ContextID + ".innerHTML = 'Loading...;" + cbReference + ";}";
scriptMgr.RegisterClientScriptBlock(this.GetType() , "CallServer", callbackScript, true);

if (!Page.IsPostBack)
{
DataColumn dc1 = new DataColumn("EmpId", typeof(System.Int32));
DataColumn dc2 = new DataColumn("Name", typeof(System.String));
DataColumn dc3 = new DataColumn("Designation", typeof(System.String));
DataColumn dc4 = new DataColumn("Salary", typeof(System.Int32));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Constraints.Add("PrimaryEmpID",dc1, true);
Session["empTable"] = dt;
}
}

please tell me how to maintain Session["empTable"] even after refresh hit??
Feb 29 '08 #1
1 3175
shweta123
692 Expert 512MB
Hi,

Try to increase the value for session timeout in web.config file. May be your session is getting expired. Also check that when first time you set the session variable if it is null or not.

hi
i'm having one application in that i'm using one session variable.
my code works fine till the user hits refresh button but
after this session variable becomes empty.

below is the code i'm using

string RenderedOutput = string.Empty;
public static int Index = 0;
DataTable dt = new DataTable();
DataRow dr;
DataView dv;

protected void Page_Load(object sender, EventArgs e)
{
ClientScriptManager scriptMgr = Page.ClientScript;
String ContextID = "__gv" + GridView1.ID.ToString() + "__div";
String cbReference = scriptMgr.GetCallbackEventReference(this, "arg", "ReceiveServerData", ContextID);
String callbackScript = "function CallServer(arg,context) {"+ ContextID + ".innerHTML = 'Loading...;" + cbReference + ";}";
scriptMgr.RegisterClientScriptBlock(this.GetType() , "CallServer", callbackScript, true);

if (!Page.IsPostBack)
{
DataColumn dc1 = new DataColumn("EmpId", typeof(System.Int32));
DataColumn dc2 = new DataColumn("Name", typeof(System.String));
DataColumn dc3 = new DataColumn("Designation", typeof(System.String));
DataColumn dc4 = new DataColumn("Salary", typeof(System.Int32));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
dt.Columns.Add(dc4);
dt.Constraints.Add("PrimaryEmpID",dc1, true);
Session["empTable"] = dt;
}
}

please tell me how to maintain Session["empTable"] even after refresh hit??
Feb 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
6
by: Colin Steadman | last post by:
I have created a function to kill all session variables that aren't in a safe list. This is the function - Sub PurgeSessionVariables For Each Item In Session.Contents Select Case Trim(Item)...
1
by: Mario | last post by:
If there is an associated memory cost for using session variables, can the memory used be reclaimed on an ASP page by setting the session variable to undefined or null? If on the same ASP page you...
2
by: lost hope | last post by:
hey all, my index.html file has 2 frames. one of the frames (left.php) sets a php session variable (using a form). this works as expected. however, when the user hits refresh on index.html,...
7
by: Nicole | last post by:
Hi I'm trying to use a function to set a session variable. I have three files: The first file has: <?php session_start(); // This connects to the existing session ?> <html> <head>
2
by: Todd | last post by:
Here's one that has been stumping people: I'm writing in ASPX with VB.NET On the login page I set the entered usename text to a session variable....
4
by: c676228 | last post by:
Hi all, In the second web form, I have the following code: (The peopleinfo is a user control which has name and ssn infomation, each field in this user control I have set enableviewstate=true). I...
1
by: tshad | last post by:
I am trying to set a session variable an find that the session variable doesn't get set until I refresh the page. I am trying to display an image with text on it (Captcha) and need to save the...
0
by: Mirovk | last post by:
Hello Agn, 1.- Being at the a.asp I refresh the page and session variables using a JavaScript function: { simbolo = window.document.frmdir.simbolo.value;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.