tags:

views:

22

answers:

1

I am settting up control propertis on page load. Like visiblilty of control depending on loaded data. And very simple setting up images to button controls. For page load it works fine but on postback these values are not set back. This is my code. When it’s a postback btnSecurityQA image is missing and visibility of all following controls is not set accordingly.

    If Not IsPostBack Then
        ButtonImage.SetPath(btnSecurityQA, GetLocalResourceObject(btnSecurityQA.ID & "BaseName").ToString())

        ' following control's visibility is set by the view interface
        Dim accountsPresenter = New AccountsPresenter
        accountsPresenter.SetAccountVisibility(Me, m_Account)
        chkMoneyMarket.Visible = _moneyMarketVisible
        lblRoutingNumber.Visible = _routingNumberVisible
        txtRoutingNumber.Visible = _routingNumberVisible
        lblSubType.Visible = _loanSubTypeVisible
        cboLoanSubType.Visible = _loanSubTypeVisible
        If Not IsNothing(m_Account) Then
            If m_Account.Id <> Guid.Empty Then
                Call PopulateLoanAccountSubTypes()
                Call PopulateData()
            End If
        End If
    End If
A: 

The code you have posted there will only run the first time the page is loaded due to the fact that it is inside a "If Not IsPostback Then" conditional statement. This code won't execute on a postback as that is what you are checking for.

bechbd
Isn't is supposed to save the values assigned first time in between postback? do I have to set these properties everytime? I thought it will save in the viewstate, that's how it worked when not loaded dynamically.. These properties are set for user control which is loaded on other page dynamically and after loading I am saving a viewsatate on parent page.
Are you sure you have Viewstate turned on for the page?
bechbd
Yest it is turned on on the page
Where is the code you have above, can you post the entire function or method? Are you sure no where else in your code is resetting these properties outside this code block? Can you post the markup?
bechbd