|
I am using Session in a web page before page load. i.e., I have a global variable which instantiates a class where current.session is used.
My current.session is nothing when I create the object for the class.
But after the Page loads, session shows all values.
Please help..
Senthil
|
|
|
|
|
Unless you set up the global variable in the session in the global.asax session.Start event you won't exist until the first page load. Unless I am missing something here?
Ben
|
|
|
|
|
Hi
in page_load im calling a function that retrieve data from the database
<small>private void getLocationStdHours()<br />
{<br />
string cacheKey = "stdHoursDS";
LocationsBL Loc = new LocationsBL();<br />
DataSet ds=Loc.GetLocationStdHours(vLocCode);<br />
<br />
Cache.Insert(cacheKey,ds,null,DateTime.Now.AddHours(1), TimeSpan.Zero);<br />
dgLocStdHours.CurrentPageIndex=0;<br />
dgLocStdHours.DataSource=((DataSet)Cache["stdHoursDS"]).Tables[0];<br />
dgLocStdHours.DataKeyField="rownum";<br />
Response.Write("before : "+((DataSet)Cache["stdHoursDS"]).Tables[0].Rows.Count);<br />
dgLocStdHours.DataBind(); <br />
<br />
btnNew.Disabled = false;<br />
}</small>
the data shows fine without problems
but when i click the "New Record" button which is a server control
private void btnNew_ServerClick(object sender, System.EventArgs e)<br />
{<br />
DataSet ds = Cache["stdHoursDS"] as DataSet;<br />
<br />
if(ds == null)<br />
{<br />
Response.Write("Session timeout - please reload page");<br />
return;<br />
}<br />
.....
the Cache["stdHoursDS"] is null now !!!
but not always in some cases it works sometimes not ?
what is the problem here ?
Note : this problem just appear when i connect from outside the local lan
using VPN or the intranet . its work prfectly from my PC or other PCs in the same lan
thanks
-- modified at 4:43 Thursday 3rd May, 2007
|
|
|
|
|
Normally the only reason why something would be kicked out of the cache before the expiration time is because the web site needed more memory so it would expire the cache before its time. NOTE you are using an absolute expire, so it will for sure expire in 1 hour. So I guess that is a possibility as well. You should write some code checking to see if the object exists in the cache before you try to use it. If it isn't there you will need to add it again.
If you didn't mean to force an expire of the dataset in 1hour then you should use the sliding expiriation. Then it will only expire if it hasn't be used for a certain period of time.
Hope that helps.
Ben
|
|
|
|
|
the problem is not appearing while i run the application in the local network !
i face the problem when i run the form throug VPN or remote connection which is slower .
i am not loosing the data after a long time i am loosing it immediately after a postback which
takes less than 2 seconeds and this happening sometimes from the first postback sometimes after 10 postbacks.
for now what i did is checking if the Dataset in the cache is still exists or not if not i am generating it again which means loosing the not saved changes .
but i want if there is an IIS configurations that could affect the cache ?
many thanks.
|
|
|
|
|
IIS controls a couple of things. In the app pool there is a recycle app pool that would re-set your entire web application, this includes the cache. By default this re-set happens like every 27 hours or something weird like that. Normally, I change it to recycle real early in the morning like 3am. The web site it self has many timeout settings for the session. I don't see any reason why a session expiring would affect the cache. I guess the question is how much data are you putting into web server memory when the post back occurs. If you are putting huge amounts of data into you web server memory then the cache could be cleared early because the server is running out of memory.
Hope that helps.
Ben
|
|
|
|
|
|
hmm, you want a menu? Look for some easy javascript
This is an simple example, its not working super but i hope i can make my point with this!
<code>
<html>
<head>
<style type="text/css">
#MenuItem{
width:150px;
border-style:solid;
height:25;
}
#subMenuItem{
width:150px;
visibility:hidden;
border-style:solid;
}
</style>
<script type="text/javascript">
function openMenu(objID)
{
document.getElementById(objID).style.visibility = 'visible';
}
function closeMenu(objID)
{
document.getElementById(objID).style.visibility = 'hidden';
}
</script>
</head>
<body>
<div id="MenuItem" onMouseOver="openMenu('SubMenuItem')">My Links</div>
<div id="SubMenuItem" onMouseOut="closeMenu('SubMenuItem')">
<lu>
<li>Link item</li>
<li>Link item</li>
<li>Link item</li>
<li>Link item</li>
</lu>
</div>
</body>
</html>
</code>
Stef
|
|
|
|
|
I am doing a project where I have to search Client on the Database so I want to search from the table where Client will Show on the data.
Romeo
|
|
|
|
|
What you did so for this application? What error it shows?
Regards,
Satips.
|
|
|
|
|
OK you want to say that your client data is in Database and you need to show that ?
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
What is SVG and its purpose? How can we use it? When will we go to SVG?
|
|
|
|
|
|
Can anybody please help me with this question ?
Role Based Menu[^]
"A good programmer is someone who looks both ways before crossing a one-way street." -- Doug Linder
coolestCoder
|
|
|
|
|
Please don't cross post one question in different forums
Thanks and Regards
Sandeep
If you want something you never had,
do something you have never done!
|
|
|
|
|
How to display Serial Numbers(1,2,3....) in DataGrid.I'm USING asp.net 1.1
Mohan Balal
|
|
|
|
|
Click[^]
There are lot of Articles Related to the Datagrid is there. This may help you.
Regards,
Satips.
|
|
|
|
|
Thanks for your Replay, If you have code or example and Post here, it will better for Me
Mohan balal
|
|
|
|
|
Just try yourself there are lot of articles there.
If you get any error means, tell your error, we will solve your problem.
Regards,
Satips.
|
|
|
|
|
Hi Mohan,
Check for the below code.
Datagrid.Databind
'After binding the datagrid
Dim item As DataGridItem
Dim i as integer=0
For Each item In Datagrid.Items
i+=1
item.Cells(0).Text=i 'Where item.Cells(0) is the first column in your datagrid if you have kept for serial number.
Next
'---------------------------------------
Or you can append the value of "i" while you are using datatable when you fill it with datareader.
Regards,
Raghu.
|
|
|
|
|
Mkanchha wrote: Thanks for Your Replay. Where to Write your code I'm using ASP.NET 1.1
Code behind File or HTML view code.
Are you a Student or an Employee?
Regards,
Satips.
|
|
|
|
|
Please tell me the difference of...OLEDB vs SQLClient..which one is better and why?
Sujit
|
|
|
|
|
these both are providers for different types of database access.
SQLClient is a provider specially optimized to work with MS SQL server, and is very well recommended to use with sql server.
on the other habd OleDB is used with MS ACCESS.
The choice is entirely yours, as to which database you want to use. accordingly u will have to chose the provider
Kunal
|
|
|
|
|
Hi To All
In my Application I want Add the file to database from webpage but I need to Drag and Drop the file to the webpage then It Should Upload to the Database. Any one Can help me
Thanking You
Sunil Tvl
|
|
|
|
|
Sure - what have you tried so far?
"Knock me down, I'll get straight back up again, I'll come back stronger than a powered up pacman"
(Lilly Allen / Kaiser Chiefs)
|
|
|
|