I'm trying to use AJAX and a MultiView control together. I've created a small example, listed below. If I remove the AJAX in my Page_Load, the code works. But if I enable the AJAX the views will no longer retain their field views when I change between the views.
--------------------
ascx.vb code:
Imports DotNetNuke
Namespace XYZ
Partial Class AjaxTest
Inherits Entities.Modules.PortalModuleBase
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
'--- remove this section to see it work ---
If DotNetNuke.Framework.AJAX.IsInstalled Then
DotNetNuke.Framework.AJAX.RegisterScriptManager()
DotNetNuke.Framework.AJAX.WrapUpdatePanelControl(PanelMain, True)
DotNetNuke.Framework.AJAX.RegisterPostBackControl(txtAmounToPay)
End If
If Not Page.IsPostBack Then
MultiView1.SetActiveView(view1)
txtAmounToPay.Text = "100.00"
ComputeFee()
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub ComputeFee()
Dim amount As Decimal = 0
Dim tax As Decimal = 0
Dim total As Decimal = 0
Try
amount = CType(txtAmounToPay.Text, Decimal)
tax = amount * 0.07
total = amount + tax
Catch ex As Exception
End Try
lblTax.Text = tax
lblTotal.Text = total
End Sub
Protected Sub txtAmounToPay_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles txtAmounToPay.TextChanged
ComputeFee()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
MultiView1.SetActiveView(view1)
End Sub
Protected Sub Button3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button3.Click
MultiView1.SetActiveView(view2)
End Sub
End Class
End Namespace
----------------
.asc.vb
<%@ Control Inherits="XYZ.AjaxTest" Language="vb" AutoEventWireup="false"
Explicit="True" CodeBehind="AjaxTest.ascx.vb" %>
<asp:Panel ID="PanelMain" runat="server">
<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="view1" runat="server">
<asp:Panel ID="Panel3" runat="server" BackColor="#CCFFFF">
View #1 ------------<br />
List of products, etc, etc.....
</asp:Panel>
</asp:View>
<asp:View ID="view2" runat="server">
<asp:Panel ID="Panel1" runat="server" BackColor="Lime">
View #2 ------------
<table width="100%">
<tr>
<td>
Sub Total:
</td>
<td>
<asp:TextBox ID="txtAmounToPay" runat="server" AutoPostBack="True">0.00</asp:TextBox>
</td>
</tr>
<tr>
<td>
Tax:
</td>
<td>
<asp:Label ID="lblTax" runat="server" Text="0.00"></asp:Label>
</td>
</tr>
<tr>
<td>
Total:
</td>
<td>
<asp:Label ID="lblTotal" runat="server" Text="0.00"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server">
</asp:Panel>
</asp:View>
</asp:MultiView>
<asp:Button ID="Button2" runat="server" Text="View 1" />
<asp:Button ID="Button3" runat="server" Text="View 2" />
</asp:Panel>
---------------------
VS2008 / DNN v 4.9.1