Here is some code:
<script runat="server">
string [] book = (string[])Session["Book"]; //this doesn't find it
void Page_Load(Object sender, EventArgs e)
{
string [] book = (string[])Session["Book"]; //this reads session var OK
screenscrape();
if (!IsPostBack) setcontrols();
}
void screenscrape ()
{
.....
}
void setcontrols ()
{
string [] book = (string[])Session["Book"]; //this doesn't find it
book1.Text=book[0];
book2.Text=book[1];
book3.Text=book[2];
}
void addbook ( Object sender, CommandEventArgs e )
{
book[Convert.ToInt32(e.CommandArgument)]=e.CommandName;
Session["Book"]=book; //doesn't work either
}
</script>
html including...
<asp:Button onCommand="addbook" text="add" runat="server"
CommandName="dictionary" CommandArgument="0" />
<asp:Button onCommand="addbook" text="add" runat="server"
CommandName="bible" CommandArgument="1" />
<asp:Button onCommand="addbook" text="add" runat="server"
CommandName="thriller" CommandArgument="2" />
As you can see i have tried string [] book=(string[])Session["Book"] in
various positions but it only works in page_load which is no good because i
need other functions to access it.