Why textbox is persisted when viewstate is off?

Discussion in 'ASP .Net' started by John Dalberg, Jul 7, 2004.

  1. John Dalberg

    John Dalberg Guest

    I have a page with a few textboxes. When the page is posted, the textfields
    retain their values even though I have viewstate turned off. It's turned
    off in 2 different places.
    - The control itself.
    - Page.EnableViewState = false; in page_load.

    How do I get the textboxes cleared after a postback without clearning them
    programmatically?

    J.
    John Dalberg, Jul 7, 2004
    #1
    1. Advertising

  2. On Wed, 7 Jul 2004 10:50:50 -0700, John Dalberg <>
    wrote:

    >
    > I have a page with a few textboxes. When the page is posted, the
    > textfields
    > retain their values even though I have viewstate turned off. It's turned
    > off in 2 different places.
    > - The control itself.
    > - Page.EnableViewState = false; in page_load.
    >
    > How do I get the textboxes cleared after a postback without clearning
    > them
    > programmatically?
    >
    > J.


    They get automatically populated with the forms' POST values. ViewState
    only stores what .NET can't get from the POST data.

    Don't know how to do this w/out programmatically clearing them, outside of
    using some JS on the client side. Perhaps someone else knows of a
    workaround...

    --
    Craig Deelsnyder
    Microsoft MVP - ASP/ASP.NET
    Craig Deelsnyder, Jul 7, 2004
    #2
    1. Advertising

  3. Textboxes don't use viewstate to retain their value property.
    Standard HTML provides a value property for textboxes so this is what
    ASP.NET uses in this case.
    Assuming your textboxes start out blank initially, you could try code like
    this to get the page to forget its values:

    Response.Redirect(".")

    The idea is that you are not posting back to your page, you are requesting a
    fresh copy.

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net


    "John Dalberg" <> wrote in message
    news:...
    >
    > I have a page with a few textboxes. When the page is posted, the

    textfields
    > retain their values even though I have viewstate turned off. It's turned
    > off in 2 different places.
    > - The control itself.
    > - Page.EnableViewState = false; in page_load.
    >
    > How do I get the textboxes cleared after a postback without clearning them
    > programmatically?
    >
    > J.
    Steve C. Orr [MVP, MCSD], Jul 7, 2004
    #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. Toby Mills
    Replies:
    0
    Views:
    1,559
    Toby Mills
    Jun 24, 2003
  2. Tom Jorgenson
    Replies:
    0
    Views:
    514
    Tom Jorgenson
    Jul 17, 2003
  3. Anthony P. Mancini
    Replies:
    8
    Views:
    410
    Victor Garcia Aprea [MVP]
    May 8, 2004
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,756
    Smokey Grindel
    Dec 2, 2006
  5. robert112
    Replies:
    1
    Views:
    426
    Juan T. Llibre
    Apr 26, 2007
Loading...

Share This Page