When you create new windows you can access the window that opened them via the opener property. You can then use the location object to reload the page.
So this could be the body tag on your page 2:
<body onunload="window.opener.location.reload([true])">
If you posted ASelected(), BSelected(), CSelected() and ddl_view0_WULValue() that would have helped more. Without that I can't really determine why it's happening. My guess is because of the lack of state in a web application. When you try to set variables in a page's code behind, objects only stay around during that single postback (in this case, a button click). The next time a button click happens, all of that data your page's private variables will be gone.
However, the state of the drop down list will be maintained between postbacks, so you can query the drop down list directly to find out what's been selected. Instead of BSelected() = 1
, I've changed it to ddl_view0.SelectedValue = "B"
I assumed that this is what your aspx page looked like. Notice the use of Text and Value properties on the ListItem. We'll use the Value property in the code to find what is selected.
<asp:MultiView runat="server" ID="mvRequestorForm" ActiveViewIndex="0"
<asp:View ID="View1" runat="server">
1
<asp:DropDownList ID="ddl_view0" runat="server">
<asp:ListItem Text="Item A" Value="A"></asp:ListItem>
<asp:ListItem Text="Item B" Value="B"></asp:ListItem>
<asp:ListItem Text="Item C" Value="C"></asp:ListItem>
<asp:ListItem Text="Item D" Value="D"></asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btn_View0_Next" runat="server" Text="Next" />
</asp:View>
<asp:View ID="View2" runat="server">
2
<asp:Button ID="btn_View1_Next" runat="server" Text="Next" />
<asp:Button ID="btn_view1_back" runat="server" Text="Back" />
</asp:View>
<asp:View ID="View3" runat="server">
3
<asp:Button ID="btn_view2_Next" runat="server" Text="Next" />
<asp:Button ID="btn_view2_back" runat="server" Text="Back" />
</asp:View>
<asp:View ID="View4" runat="server">
4
<asp:Button ID="btn_view3_back" runat="server" Text="Back" />
</asp:View>
</asp:MultiView>
I've changed your code to get rid of all of the ASelected(), BSelected, CSelected, and dll_view0_WULValue() calls and just use the drop down list directly.
Protected Sub btn_view1_back_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_view1_back.Click, btn_view2_back.Click, btn_view3_back.Click
'Try'
If mvRequestorForm.ActiveViewIndex = 3 And ddl_view0.SelectedValue = "B" Then 'CHANGED to use the SelectedValue property of the dropdownlist because it keeps state properly'
mvRequestorForm.ActiveViewIndex -= 2 'CHANGED to a cleaner way to decrement by 2'
Else
mvRequestorForm.ActiveViewIndex -= 1 'CHANGED to a cleaner way to decrement by 1'
End If
If mvRequestorForm.ActiveViewIndex = 1 Then 'NOTE: This is now at least one less than when the method started. Is this what you really wanted?'
If (ddl_view0.SelectedValue = "C") Then 'CHANGED to use the SelectedValue property of the dropdownlist because it keeps state properly'
strRoleType = "chkBx_C_workunit"
ElseIf (ddl_view0.SelectedValue = "A") Then 'CHANGED to use the SelectedValue property of the dropdownlist because it keeps state properly'
strRoleType = "chkBx_A_workunit"
ElseIf (ddl_view0.SelectedValue = "B") Then 'CHANGED to use the SelectedValue property of the dropdownlist because it keeps state properly'
strRoleType = "chkBx_B_workunit"
End If
'NOTE: There seemed to be a duplicate case for "B" here, so I removed it'
End If
'Catch ex As Exception'
'Commented out Try/Catch because empty catches hide bugs and make development harder'
'End Try'
End Sub
Protected Sub btn_View0_Next_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_View0_Next.Click, btn_View1_Next.Click, btn_view2_Next.Click
'Try'
If mvRequestorForm.ActiveViewIndex = 1 And ddl_view0.SelectedValue = "B" Then
mvRequestorForm.ActiveViewIndex += 2 'CHANGED to a cleaner way to increment by 2'
rfv_view2_managersEmail.Enabled = True
rev_view2_managersEmail.Enabled = True
Else
mvRequestorForm.ActiveViewIndex += 1 'CHANGED to a cleaner way to increment by 1'
End If
If mvRequestorForm.ActiveViewIndex = 1 Then 'NOTE: This is now at least one more than when the method started. Is this what you really wanted?'
'Sub_ActivateView1()'
End If
'Catch ex As Exception'
'Commented out Try/Catch because empty catches hide bugs and make development harder'
'End Try'
End Sub
I don't know what strRoleType is for, but that probably won't work correctly either. If it doesn't, try dropping a HiddenField control on your form and use that to store the value.
Best Answer
This is just a guess based on what you've told me so far:
If you are storing the details of previous selections in the Session make sure the session is not set for InProc. InProc session is incompatible with most ways of configuring a load-balancer (although it can be done with various things like sticky IP or sticky session settings [if the Load balancer supports it])