What's a quick way to find out if an ASP.NET control property is supported by a viewstate or normal?
In all my Page_Load () events I need to do
if(!IsPostBack)
{
//code runs on initial get
//Set properties backed by viewstate
}
else
{
//Code runs on each get and post
//Set properties backed by ordinary fields
}
Is there any quick way to spot this reflector flaw, by reading the documentation, or creating a test page?
Are you better off accepting the convention that the viewstate doesn't actually exist because you don't know if it works without examining it across all the potentially 1000 properties that might be required to be set in a large line of a business application
a source to share
It's like a design question - when to use ViewState. Since you have the source, you obviously know which controls are using the ViewState, so no guesswork or discovery is required.
IsPostback is the usual way of defining GET or POST. You can also look at Request.HttpMethod. For deciding when to use ViewState, will the page postback until its task completes (for example, update some controls based on user actions)? If you will be Postbck and the cost of filling all fields is too high, use ViewState. Or use Ajax calls to avoid Postbacks just to update content.
Remember, when you do Postback, you don't need ViewState to read values. The controls are passed to the collection of the form.
a source to share