WebControl State: ViewState or Request.Form?

Discussion in 'ASP .Net' started by Patrice, Aug 31, 2004.

  1. Patrice

    Patrice Guest

    See :
    http://support.microsoft.com/default.aspx?scid=kb;EN-US;316813

    Looks like to me it's best to use form values as they are already available
    and viewstate for all other properties that are not part of the submit
    process... Anyway you can get the news value only from the forms collection.

    Patrice

    --

    "Hadar" <> a écrit dans le message de
    news:...
    > Hi,
    >
    > I'm still a little bit confused with how managing a webcontrol state over
    > postbacks...
    > Should I use the form's post values to populate the control on the server
    > side when possible, or should I always use the viewstate mechanism?
    >
    > For instance, I noticed that the TextBox webcontrol does not depend on the
    > viewstate.
    > I guess it uses the form to retrieve state (the input is submited of

    course)
    > over roundtrips...
    >
    > Also, the control should manage its state independenty.
    > No matter if it is used directly by the page, or by a parent composite
    > control it should save state by its own (like the TextBox webcontrol).
    >
    > Thanks,
    > Hadar
    >
    >
    >
    >
    >
    Patrice, Aug 31, 2004
    #1
    1. Advertising

  2. Patrice

    Teemu Keiski Guest

    Basically it is dependant on what you intend the control to do and how to
    work.As was said, there is no preset rule, it all depends on the
    functionality of the control and what it does over the postbacks. Also what
    it uses as underlying HTML elements is crucial (some of them are posted,
    some aren't).

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke


    "Hadar" <> wrote in message
    news:...
    > Hi,
    >
    > I'm still a little bit confused with how managing a webcontrol state over
    > postbacks...
    > Should I use the form's post values to populate the control on the server
    > side when possible, or should I always use the viewstate mechanism?
    >
    > For instance, I noticed that the TextBox webcontrol does not depend on the
    > viewstate.
    > I guess it uses the form to retrieve state (the input is submited of

    course)
    > over roundtrips...
    >
    > Also, the control should manage its state independenty.
    > No matter if it is used directly by the page, or by a parent composite
    > control it should save state by its own (like the TextBox webcontrol).
    >
    > Thanks,
    > Hadar
    >
    >
    >
    >
    >
    Teemu Keiski, Aug 31, 2004
    #2
    1. Advertising

  3. Patrice

    Hadar Guest

    Hi,

    I'm still a little bit confused with how managing a webcontrol state over
    postbacks...
    Should I use the form's post values to populate the control on the server
    side when possible, or should I always use the viewstate mechanism?

    For instance, I noticed that the TextBox webcontrol does not depend on the
    viewstate.
    I guess it uses the form to retrieve state (the input is submited of course)
    over roundtrips...

    Also, the control should manage its state independenty.
    No matter if it is used directly by the page, or by a parent composite
    control it should save state by its own (like the TextBox webcontrol).

    Thanks,
    Hadar
    Hadar, Aug 31, 2004
    #3
  4. Hadar,

    There is no general answer to your question. There is a number of factors to
    consider. Imagine you have a dropdown list that you populate with just a few
    lines but in order to obtain the lines you have to run a heavy database
    query. Then, obviously, you would prefer running the query once and saving
    the lines in the viewstate. In other case, when you have a dropdown list for
    selecting time of day with 15 minutes increment, you would prefer populating
    the list with a few lines of code on every round trip.

    Eliyahu

    "Hadar" <> wrote in message
    news:...
    > Hi,
    >
    > I'm still a little bit confused with how managing a webcontrol state over
    > postbacks...
    > Should I use the form's post values to populate the control on the server
    > side when possible, or should I always use the viewstate mechanism?
    >
    > For instance, I noticed that the TextBox webcontrol does not depend on the
    > viewstate.
    > I guess it uses the form to retrieve state (the input is submited of

    course)
    > over roundtrips...
    >
    > Also, the control should manage its state independenty.
    > No matter if it is used directly by the page, or by a parent composite
    > control it should save state by its own (like the TextBox webcontrol).
    >
    > Thanks,
    > Hadar
    >
    >
    >
    >
    >
    Eliyahu Goldin, Aug 31, 2004
    #4
    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. shamanthakamani
    Replies:
    1
    Views:
    3,490
    Natty Gur
    Nov 20, 2003
  2. Not Liking Dot Net Today
    Replies:
    0
    Views:
    609
    Not Liking Dot Net Today
    Apr 21, 2004
  3. Maciek
    Replies:
    0
    Views:
    8,248
    Maciek
    Sep 15, 2005
  4. Harry Haller
    Replies:
    0
    Views:
    1,655
    Harry Haller
    Nov 7, 2006
  5. Hadar

    WebControl State: ViewState or Request.Form?

    Hadar, Aug 31, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    138
    Hadar
    Aug 31, 2004
Loading...

Share This Page