T
Tony Johansson
Hello!
Here is the text.
"One technique to store state on the client is to use ViewState. ViewState
is used automatically by the Web server control to make events work. The
ViewState contains the same state as the control when sent to the client.
When the browser sends the form back to the server, the ViewState contains
the original values, but the values of the control that are sent contains
the new values. If there's a difference, the corresponding event handlers
will be invoked."
Here is an example how the ViewState works.
Assume that you have a label and two buttons.
The label.text is initialized with "StartInit""
One of the buttons is called ChangeMessage and the other button is called
EmptyPostback
Assume that you use the default which is EnableViewState="true"
The ChangeMessage has an eventhandler.In this eventhandler you change the
label.text = "newChange"
If you now run the WebSite and click on EmptyPostback nothing happens
because this only cause a postback without any executing any code.
If you now click on the ChangeMessage the label on the browser is displayed
as newChange and if you click on EmptyPostback the newChange is still being
displayed in the browser.
Now if you set EnableViewState="false" and run the WebSite you will get a
different result.
If you click on EmptyPostback nothing happens because only a postback is
sent but no code is being executed.
If you click on ChangeMessage the label is displayed as newChange and if you
not click on EmptyPostback the label is changed back to StartInit because
the ViewState is not saved.
So as a summary I can't figure out what the text mean with this text "When
the browser sends the form back to the server, the ViewState contains the
original values, but the values of the control that are sent contains the
new values. If there's a difference, the corresponding event handlers will
be invoked."
I mean that setting EnableViewState="true" only save property changes as in
the example I gave.
//Tony
Here is the text.
"One technique to store state on the client is to use ViewState. ViewState
is used automatically by the Web server control to make events work. The
ViewState contains the same state as the control when sent to the client.
When the browser sends the form back to the server, the ViewState contains
the original values, but the values of the control that are sent contains
the new values. If there's a difference, the corresponding event handlers
will be invoked."
Here is an example how the ViewState works.
Assume that you have a label and two buttons.
The label.text is initialized with "StartInit""
One of the buttons is called ChangeMessage and the other button is called
EmptyPostback
Assume that you use the default which is EnableViewState="true"
The ChangeMessage has an eventhandler.In this eventhandler you change the
label.text = "newChange"
If you now run the WebSite and click on EmptyPostback nothing happens
because this only cause a postback without any executing any code.
If you now click on the ChangeMessage the label on the browser is displayed
as newChange and if you click on EmptyPostback the newChange is still being
displayed in the browser.
Now if you set EnableViewState="false" and run the WebSite you will get a
different result.
If you click on EmptyPostback nothing happens because only a postback is
sent but no code is being executed.
If you click on ChangeMessage the label is displayed as newChange and if you
not click on EmptyPostback the label is changed back to StartInit because
the ViewState is not saved.
So as a summary I can't figure out what the text mean with this text "When
the browser sends the form back to the server, the ViewState contains the
original values, but the values of the control that are sent contains the
new values. If there's a difference, the corresponding event handlers will
be invoked."
I mean that setting EnableViewState="true" only save property changes as in
the example I gave.
//Tony