M
Mark Fitzpatrick
Every time the page is loaded, the variable is re-created. The page itself
is inherently stateless, but you can save variables into the viewstate of
the page in an attempt to retain their state. Before you fetch anything from
the viewstate, just check to make sure it isn't null for some reason.
if(ViewState["TimeStr"] != null)
{
string temp = ViewState["TimeStr"].ToString();
ViewState["TimeStr"] = (temp + ("<br>" +
System.DateTime.Now.ToString()));
}
else
{
ViewState["TimeStr"] = ("<br>" + System.DateTime.Now.ToString());
}
You'll forgive me if the above code is in C#, but it's been too long since I
worked with VB.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
is inherently stateless, but you can save variables into the viewstate of
the page in an attempt to retain their state. Before you fetch anything from
the viewstate, just check to make sure it isn't null for some reason.
if(ViewState["TimeStr"] != null)
{
string temp = ViewState["TimeStr"].ToString();
ViewState["TimeStr"] = (temp + ("<br>" +
System.DateTime.Now.ToString()));
}
else
{
ViewState["TimeStr"] = ("<br>" + System.DateTime.Now.ToString());
}
You'll forgive me if the above code is in C#, but it's been too long since I
worked with VB.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage