We are using Sharepoint 2007
We initialising the session variable on page load
We have one javascript function as mentioned below
function backclick()
{
__doPostBack('btnCaseSearch', 'Click');
alert('Select the Search Criteria.');
}
but after calling this we are losing session value.
If we remove __doPostBack(‘btnCaseSearch’, ‘Click’);
then alert is displaying each time when page gets load but session is not losing its value.
How to maintain session pls help or suggest some alternative to _doPostBack()
the sceneario is like this
below javascript function
function backclick()
{
__doPostBack('btnCaseSearch', 'Click');
alert(result not found.');
}
function check()
{
var btn ="<%=Session["search"]%>";
if(btn == "true")
{
do something
}
else
{
else part
}
Below server side code
Page_Load()
{
//initialise session variable
session["search"] = "true";
}
btnSearch_click()
{
if(result not found)
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(),"page_index_script1", "backclick();", true);
}
}
so when backclick() javascript function gets called at that time session is losing its state but if backclick() doesn’t get called then code works perferctly
Thanks
Something which jumped out at me:
Is this page load server-side?
Each time you
_doPostBackwill cause pageLoad to execute, so I believe this is where you’re overwriting your session variable.The only way the session will loose it’s state is:
Check both of these and if your problem isn’t solved post what you found.