473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

WebControl State: ViewState or Request.Form?

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

Nov 18 '05 #1
3 1884
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" <cr****@bezeqint.net> wrote in message
news:OK**************@TK2MSFTNGP09.phx.gbl...
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


Nov 18 '05 #2
See :
http://support.microsoft.com/default...b;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" <cr****@bezeqint.net> a écrit dans le message de
news:OK**************@TK2MSFTNGP09.phx.gbl...
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


Nov 18 '05 #3
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" <cr****@bezeqint.net> wrote in message
news:OK**************@TK2MSFTNGP09.phx.gbl...
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


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
1
by: Marri Suliez | last post by:
Does anyone know how the Style property of the WebControl class persists between calls as if it's added to the ViewState? CssStyleCollection is not serializable. The following scenario leads me...
0
by: Mike Hofer | last post by:
Hi everyone. I could really use some help. First, the backstory: ===================== I *really* need a 3-state checkbox for my ASP.NET application. Specifically, I need one that lets me set...
1
by: Mike Hofer | last post by:
I have a webcontrol that has the following property defined: <Category("Behavior"), PersistenceMode(PersistenceMode.Attribute),...
9
by: McGeeky | last post by:
Is there a way to get a user control to remember its state across pages? I have a standard page layout I use with a header and footer as user controls. Each page uses the same layout by means of...
3
by: Neven Klofutar | last post by:
Hi, I recently read an article on MSDN about viewstate and postback. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.asp The author states the following:...
8
by: mark.norgate | last post by:
I've asked this question before, but still haven't solved it, so am asking again. I am programmatically adding a user control to the page in response to a button click. The user control consists...
2
by: archana | last post by:
Hi all, I am new to asp.net. I am not very much clear in concept of viewstate. CAn anyone help me in understanding this concept. I have one question regarding viewstate. I have one aspx...
1
by: =?Utf-8?B?YWJjZA==?= | last post by:
My application is using ASP.NET 3.0 and My ASPX pages contain Master page, and content page. The content page (.aspx) has various User controls (ascx). My page view state is significantly large and...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.