Firstly I see you posted
here a while ago, and some kind person already replied,
QUOTE
I am afraind that when you set the PostBackUrl for a LinkButton, the code in the lnk1_Click will never execute, and the value never be stored in the session.
You are using the AccessKey property of the LinkButton AND you are setting the postback url to include your session key value. But you never attempt to use the value posted back in the url.
What are you trying to achieve?
If I want to set up some kind of artificial session id then I use code similar to the following:
CODE
int mySessionId = 0;
if (Session["MySessionId"] == null)
{
mySessionId = CreateNewSessionId(); // some method to create a session id
Session["MySessionId"] = mySessionId;
}
else
{
try
{
mySessionId = Convert.ToInt32(Session["MySessionId"]);
}
catch (FormatException) { }
}
The whole point of the session is that it is able to store data at the server. The default timeout for a session is 20 minutes I think, so that data will cease to exist after this time.
If you want to store a session id at the client then why not try storing it in the
ViewState.
Hope this helps!