Newbies Question on data variables

Discussion in 'ASP .Net' started by Vivian, Jul 12, 2006.

  1. Vivian

    Vivian Guest

    I have an aspx page with C# with several "post" button. Each button will do
    sth, and return some data to the same page. The problem is I have a public
    variable, say tmpA in C# in which data will set while the first button is
    clicked. I need to get the value of tmpA when pressing other button, the
    problem is how can I save the value of tmpA?
    Do I need to add a hidden field on the form to do that?
    Or is there any better approach? Thanks
     
    Vivian, Jul 12, 2006
    #1
    1. Advertising

  2. Are you asking how to preserve variables between postbacks? If this is what
    you mean, put them in the VewState:

    int tempA;
    ....
    ViewState["TEMPA"] = tempA;
    ....
    tempA = (int)ViewState["TEMPA"];
    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]

    "Vivian" <> wrote in message
    news:...
    >I have an aspx page with C# with several "post" button. Each button will do
    >sth, and return some data to the same page. The problem is I have a public
    >variable, say tmpA in C# in which data will set while the first button is
    >clicked. I need to get the value of tmpA when pressing other button, the
    >problem is how can I save the value of tmpA?
    > Do I need to add a hidden field on the form to do that?
    > Or is there any better approach? Thanks
    >
     
    Eliyahu Goldin, Jul 12, 2006
    #2
    1. Advertising

  3. Vivian

    Vivian Guest

    Thanks. That's what I need.

    "Eliyahu Goldin" <> ¼¶¼g©ó¶l¥ó·s»D:...
    > Are you asking how to preserve variables between postbacks? If this is
    > what you mean, put them in the VewState:
    >
    > int tempA;
    > ...
    > ViewState["TEMPA"] = tempA;
    > ...
    > tempA = (int)ViewState["TEMPA"];
    > --
    > Eliyahu Goldin,
    > Software Developer & Consultant
    > Microsoft MVP [ASP.NET]
    >
    > "Vivian" <> wrote in message
    > news:...
    >>I have an aspx page with C# with several "post" button. Each button will
    >>do sth, and return some data to the same page. The problem is I have a
    >>public variable, say tmpA in C# in which data will set while the first
    >>button is clicked. I need to get the value of tmpA when pressing other
    >>button, the problem is how can I save the value of tmpA?
    >> Do I need to add a hidden field on the form to do that?
    >> Or is there any better approach? Thanks
    >>

    >
    >
     
    Vivian, Jul 12, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joona I Palaste

    Question about newbies and interfaces

    Joona I Palaste, Nov 30, 2003, in forum: Java
    Replies:
    2
    Views:
    343
    Chris Uppal
    Nov 30, 2003
  2. Chinmoy Mukherjee

    newbies question about return value

    Chinmoy Mukherjee, Jun 14, 2005, in forum: C++
    Replies:
    3
    Views:
    314
    Jim Langston
    Jun 15, 2005
  3. Alexander Baranov

    Stream Redirection. Newbies question

    Alexander Baranov, Oct 25, 2004, in forum: C Programming
    Replies:
    2
    Views:
    291
    Dan Pop
    Oct 25, 2004
  4. Alf P. Steinbach

    How we recognize newbies as newbies

    Alf P. Steinbach, Aug 13, 2007, in forum: C++
    Replies:
    31
    Views:
    1,156
    Diego Martins
    Aug 21, 2007
  5. SonOfLilit
    Replies:
    39
    Views:
    308
    Austin Ziegler
    Aug 16, 2007
Loading...

Share This Page