Use of ViewState in User control
During development of user controls in EP, if you wish to preserve the state(value) of Page Level variables , you can use ViewState available in EP Framework in Ax2009. This is useful because Enterprise portal by default is stateless and if data need to persisted across various postbacks events in web control for example in a Dataset, ViewState comes as a handy option.
Scenario : When a button is clicked on user control or user goes to next page in a Web control which uses a wizard , then a postback event is fired and value of page level variables is lost.
Usage : Use the following code to store the variable under ViewState
ViewState[“InvoiceId”] = invoiceId;
And to retrieve the value , use code below
invoiceId = ViewState[“InvoiceId”]