Learning problems...

  • Thread starter Thread starter newsgroupie
  • Start date Start date
N

newsgroupie

Hi Newsgroupies,

I have a friend with 10 years MFC experience and who is now learning C#
and WebForms and who has run up against a conceptual problem.

I, erm I mean he, wants to know how to save and restore information
between renderings of a WebForms page before during and after a button
click for example.

A useful example would be to increment a number on each press of a
button and then paste the new value as the buttons text.

Many thanks!

Newsgroupie & friend
 
Some ideas:
Session state
ViewState
Hidden input fields

Different ones are good for different types of situations and have their own
advantages and disadvantages. You can find tons of info about each approach
on google.
 
newsgroupie said:
Hi Newsgroupies,

I have a friend with 10 years MFC experience and who is now learning C#
and WebForms and who has run up against a conceptual problem.

I, erm I mean he, wants to know how to save and restore information
between renderings of a WebForms page before during and after a button
click for example.

A useful example would be to increment a number on each press of a button
and then paste the new value as the buttons text.

Drop a button on your webform and put this code behind it:

private void Button1_Click(object sender, System.EventArgs e)
{
if (Session["WebForm1.HitCount"] == null)
{
Session["WebForm1.HitCount"] = 0;
}
int i = (int)Session["WebForm1.HitCount"];
i += 1;
Session["WebForm1.HitCount"] = i;
Button1.Text = "HitCount: " + i;
}



David
 
Thanks Maria!

That's exactly the sort of thing I, erm I mean he was looking for;
Application/Session State

;-)

Newsgroupie, UK
 
Back
Top