Simple question on Viewstate

Discussion in 'ASP .Net' started by Danny, Nov 15, 2003.

  1. Danny

    Danny Guest

    Hi,

    I have a very simple asp.net application with a webform and an integer data
    member. I've placed a button on this form which increments the integer data
    member by 1 each time it is clicked and displays it with Response.Write.
    The data member's value is not saved in each button click, and the value
    always stays the same.
    I have viewstate enabled for the page.
    How can I change this behavour ?

    Thanks,

    Danny
     
    Danny, Nov 15, 2003
    #1
    1. Advertising

  2. Danny

    rovshan Guest

    Hi,

    if that member is simply a class member you will not have
    it's value saved between posts. Consider keeping it in
    ViewState

    Thanks,
    Rovshan

    >-----Original Message-----
    >Hi,
    >
    >I have a very simple asp.net application with a webform

    and an integer data
    >member. I've placed a button on this form which

    increments the integer data
    >member by 1 each time it is clicked and displays it with

    Response.Write.
    >The data member's value is not saved in each button

    click, and the value
    >always stays the same.
    >I have viewstate enabled for the page.
    >How can I change this behavour ?
    >
    >Thanks,
    >
    >Danny
    >
    >
    >.
    >
     
    rovshan, Nov 15, 2003
    #2
    1. Advertising

  3. Danny

    Danny Guest

    Ok, then how do you suggest this should be done?
    What if it's an object such as an enumerator I want to keep? And one last
    question - in case of a mobile form, I don't have ViewState. Are there any
    alternatives?

    "rovshan" <> wrote in message
    news:08f901c3ab83$4f551f70$...
    > Hi,
    >
    > if that member is simply a class member you will not have
    > it's value saved between posts. Consider keeping it in
    > ViewState
    >
    > Thanks,
    > Rovshan
    >
    > >-----Original Message-----
    > >Hi,
    > >
    > >I have a very simple asp.net application with a webform

    > and an integer data
    > >member. I've placed a button on this form which

    > increments the integer data
    > >member by 1 each time it is clicked and displays it with

    > Response.Write.
    > >The data member's value is not saved in each button

    > click, and the value
    > >always stays the same.
    > >I have viewstate enabled for the page.
    > >How can I change this behavour ?
    > >
    > >Thanks,
    > >
    > >Danny
    > >
    > >
    > >.
    > >
     
    Danny, Nov 15, 2003
    #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. Ben Rush
    Replies:
    2
    Views:
    527
    Ben Rush
    Dec 5, 2003
  2. Steph
    Replies:
    2
    Views:
    1,665
    heislord5
    May 11, 2011
  3. ujjc001
    Replies:
    0
    Views:
    1,371
    ujjc001
    Jul 27, 2005
  4. sck10
    Replies:
    6
    Views:
    917
    sck10
    Sep 1, 2006
  5. mark

    Viewstate errors... how do I get viewstate working?

    mark, Feb 20, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    278
Loading...

Share This Page