Add attributes after viewstate has been saved.

Discussion in 'ASP .Net' started by Tom Vergote, Jan 28, 2004.

  1. Tom Vergote

    Tom Vergote Guest

    Hi all,

    I have this page with quite a few textboxes which require viewstate ON.
    However, i execute some Control.Addatributes on them so the take very much
    viewstate space (three times a normal textbox). Those attributes can easily
    be readded with every request, so those don't need to be in the viewstate,
    only what the user entered in it.

    I am looking for a way of having only the value of the textbox saved but not
    the attributes i added.

    I know Page_Render comes after saving to the viewstate, but can I use that
    to add the attributes after the viewstate has been saved? It doesn't work
    for me after a few shots and I don't seem to find any info or reference.

    Any info would be appreciated

    Tom Vergote
    MCsomething and another
    Tom Vergote, Jan 28, 2004
    #1
    1. Advertising

  2. Write your code in Page_Prerender method .

    --
    Saravana
    Microsoft MVP - ASP.NET
    www.extremeexperts.com



    "Tom Vergote" <tom.vergote@[spamtrap]orbid.be> wrote in message
    news:4017887a$0$324$...
    > Hi all,
    >
    > I have this page with quite a few textboxes which require viewstate ON.
    > However, i execute some Control.Addatributes on them so the take very much
    > viewstate space (three times a normal textbox). Those attributes can

    easily
    > be readded with every request, so those don't need to be in the viewstate,
    > only what the user entered in it.
    >
    > I am looking for a way of having only the value of the textbox saved but

    not
    > the attributes i added.
    >
    > I know Page_Render comes after saving to the viewstate, but can I use that
    > to add the attributes after the viewstate has been saved? It doesn't work
    > for me after a few shots and I don't seem to find any info or reference.
    >
    > Any info would be appreciated
    >
    > Tom Vergote
    > MCsomething and another
    >
    >
    Saravana [MVP], Jan 28, 2004
    #2
    1. Advertising

  3. Tom Vergote

    Tom Vergote Guest

    Saravana,

    Thanks for your reply.
    if I am not mistaken, the prerender method comes before saving the
    viewstate (at least thats what the trace output tells me)

    Tom Vergote

    Was it not Saravana [MVP] who claimed:

    > Write your code in Page_Prerender method .
    >
    > --
    > Saravana
    > Microsoft MVP - ASP.NET
    > www.extremeexperts.com
    >
    >
    >
    > "Tom Vergote" <tom.vergote@[spamtrap]orbid.be> wrote in message
    > news:4017887a$0$324$...
    >> Hi all,
    >>
    >> I have this page with quite a few textboxes which require viewstate ON.
    >> However, i execute some Control.Addatributes on them so the take very much
    >> viewstate space (three times a normal textbox). Those attributes can

    > easily
    >> be readded with every request, so those don't need to be in the viewstate,
    >> only what the user entered in it.
    >>
    >> I am looking for a way of having only the value of the textbox saved but

    > not
    >> the attributes i added.
    >>
    >> I know Page_Render comes after saving to the viewstate, but can I use that
    >> to add the attributes after the viewstate has been saved? It doesn't work
    >> for me after a few shots and I don't seem to find any info or reference.
    >>
    >> Any info would be appreciated
    >>
    >> Tom Vergote
    >> MCsomething and another
    >>
    >>
    Tom Vergote, Jan 28, 2004
    #3
  4. Yes, prerender fires before saveviewstate happens. If you just want to
    persist only the text value of textbox across postback, then just disable
    Viewstate for that controls. Text is a property that does not need to be
    stored in ViewState as this is available through the Form collection and the
    value will be replaced with the Form value when Postback data is processed
    before the Load Event.


    --
    Saravana
    Microsoft MVP - ASP.NET
    www.extremeexperts.com



    "Tom Vergote" <> wrote in message
    news:p...
    > Saravana,
    >
    > Thanks for your reply.
    > if I am not mistaken, the prerender method comes before saving the
    > viewstate (at least thats what the trace output tells me)
    >
    > Tom Vergote
    >
    > Was it not Saravana [MVP] who claimed:
    >
    > > Write your code in Page_Prerender method .
    > >
    > > --
    > > Saravana
    > > Microsoft MVP - ASP.NET
    > > www.extremeexperts.com
    > >
    > >
    > >
    > > "Tom Vergote" <tom.vergote@[spamtrap]orbid.be> wrote in message
    > > news:4017887a$0$324$...
    > >> Hi all,
    > >>
    > >> I have this page with quite a few textboxes which require viewstate ON.
    > >> However, i execute some Control.Addatributes on them so the take very

    much
    > >> viewstate space (three times a normal textbox). Those attributes can

    > > easily
    > >> be readded with every request, so those don't need to be in the

    viewstate,
    > >> only what the user entered in it.
    > >>
    > >> I am looking for a way of having only the value of the textbox saved

    but
    > > not
    > >> the attributes i added.
    > >>
    > >> I know Page_Render comes after saving to the viewstate, but can I use

    that
    > >> to add the attributes after the viewstate has been saved? It doesn't

    work
    > >> for me after a few shots and I don't seem to find any info or

    reference.
    > >>
    > >> Any info would be appreciated
    > >>
    > >> Tom Vergote
    > >> MCsomething and another
    > >>
    > >>

    >
    Saravana [MVP], Jan 29, 2004
    #4
  5. Tom Vergote

    Tom Vergote Guest

    Great,

    I wasn't aware that form values get re-loaded to form fields, even if the
    viewstate for that control is off.
    I'll be switching of more viewstates at the page level from now on, because
    apparently you don't need viewstate to reload the form fields with the
    entered values.

    Thanks a million
    Tom

    --
    Tom Vergote / Developer
    ORBID / IT Services
    Tramstraat 61 / B-9052 GENT
    Tel +32 (0)9 244 99 45 / +32 (0)9 244 99 96
    http://www.orbid.be

    "Saravana [MVP]" <> wrote in message
    news:...
    > Yes, prerender fires before saveviewstate happens. If you just want to
    > persist only the text value of textbox across postback, then just disable
    > Viewstate for that controls. Text is a property that does not need to be
    > stored in ViewState as this is available through the Form collection and

    the
    > value will be replaced with the Form value when Postback data is processed
    > before the Load Event.
    >
    >
    > --
    > Saravana
    > Microsoft MVP - ASP.NET
    > www.extremeexperts.com
    >
    >
    >
    > "Tom Vergote" <> wrote in

    message
    > news:p...
    > > Saravana,
    > >
    > > Thanks for your reply.
    > > if I am not mistaken, the prerender method comes before saving the
    > > viewstate (at least thats what the trace output tells me)
    > >
    > > Tom Vergote
    > >
    > > Was it not Saravana [MVP] who claimed:
    > >
    > > > Write your code in Page_Prerender method .
    > > >
    > > > --
    > > > Saravana
    > > > Microsoft MVP - ASP.NET
    > > > www.extremeexperts.com
    > > >
    > > >
    > > >
    > > > "Tom Vergote" <tom.vergote@[spamtrap]orbid.be> wrote in message
    > > > news:4017887a$0$324$...
    > > >> Hi all,
    > > >>
    > > >> I have this page with quite a few textboxes which require viewstate

    ON.
    > > >> However, i execute some Control.Addatributes on them so the take very

    > much
    > > >> viewstate space (three times a normal textbox). Those attributes can
    > > > easily
    > > >> be readded with every request, so those don't need to be in the

    > viewstate,
    > > >> only what the user entered in it.
    > > >>
    > > >> I am looking for a way of having only the value of the textbox saved

    > but
    > > > not
    > > >> the attributes i added.
    > > >>
    > > >> I know Page_Render comes after saving to the viewstate, but can I use

    > that
    > > >> to add the attributes after the viewstate has been saved? It doesn't

    > work
    > > >> for me after a few shots and I don't seem to find any info or

    > reference.
    > > >>
    > > >> Any info would be appreciated
    > > >>
    > > >> Tom Vergote
    > > >> MCsomething and another
    > > >>
    > > >>

    > >

    >
    >
    Tom Vergote, Jan 29, 2004
    #5
    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. =?Utf-8?B?TWVyZGFhZA==?=
    Replies:
    5
    Views:
    5,846
    neskire
    Nov 7, 2006
  2. =?Utf-8?B?TWVyZGFhZA==?=
    Replies:
    0
    Views:
    347
    =?Utf-8?B?TWVyZGFhZA==?=
    Oct 20, 2004
  3. Jim Bancroft
    Replies:
    4
    Views:
    9,193
    Saravana
    Jan 6, 2005
  4. bill.wu
    Replies:
    0
    Views:
    285
    bill.wu
    Jan 17, 2008
  5. S.Sigal
    Replies:
    0
    Views:
    129
    S.Sigal
    Aug 14, 2004
Loading...

Share This Page