Question

I have 3 webparts which together will create a table with data in it. The webparts work as follows: LoginWP: A user can enter username and password in 2 textfields and then click on a login button. This activates the login function. This webpart will now provide a ticket which is used to check if the user is logged in.

TypeWP: This web part activates when LoginWP can provide a webpart and uses this login ticket to get Document Types and load these in a ComboBoxList. If a document type is selected this webpart will now provide both the ticket and the document type.

TableWP: This web part will activate when TypeWP provides both a ticket and a document type. It uses both variables to load data into the table.

When the login button is clicked TypeWP will automatically select a first document type and thus activate TableWP. Up to now it all works as expected. Now when i select a different item in the ComboBoxList, TypeWP will lose LoginWP as it's provider and therefore lose it's provider.

After some debugging i managed to find out that the CreateChildControls() of the TypeWP is called when i change the selected comboboxitem. in this CreateChildControls it checks if the LoginWP Provider excists. At this point it doesn't and so the function stops. The next function called is the CreateChildControls of the LoginWP and it creates the provider TypeWP was looking for.

So my question is: How can i prevent the loginWP from recreating itself when i chance the selected item in the combobox or can i save the ticket variable somewhere else so it will be available as long as the user is on the page?

Was it helpful?

Solution

I traced the error back and used the

CreateChildControls()

and the

OnPreRender()

functions wrong causing the error. I checked for the provider inside the CreateChildControl function. But since the CreateChildControl function of the provider wasn't called yet it couldn't find it. Moving the check and the variable call to OnPreRender solved the error.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top