Re: UploadAttachments loses file info during multiple postbacks (Viewstate is enabled)

  •  03-15-2012, 9:52 AM

    Re: UploadAttachments loses file info during multiple postbacks (Viewstate is enabled)

    Hi thorn,
     
    I created an example with the asp:MultiView control, please try it on your end. Does it work?
     
    <%@ Page Language="C#" %>
    <%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
    <html>
    <head>
        <script runat="server">
            protected override void OnPreRender(EventArgs e)
            {
                base.OnPreRender(e);
                uploader1.Items.ToString();
            }
            protected void NextButton_Command(object sender, EventArgs e)
            {
                if (DevPollMultiView.ActiveViewIndex > -1 & DevPollMultiView.ActiveViewIndex < 2)
                {
                    DevPollMultiView.ActiveViewIndex += 1;
                }
            }
            protected void BackButton_Command(object sender, EventArgs e)
            {
                if (DevPollMultiView.ActiveViewIndex > 0 & DevPollMultiView.ActiveViewIndex <= 2)
                {
                    DevPollMultiView.ActiveViewIndex -= 1;
                }
                else if (DevPollMultiView.ActiveViewIndex == 2)
                {
                    DevPollMultiView.ActiveViewIndex = 0;
                }
                else
                {
                    throw new Exception("An error occurred.");
                }
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="Server">
        <asp:Panel ID="Page1ViewPanel" Width="330px" Height="150px" HorizontalAlign="Left"
            runat="Server">
            <asp:MultiView ID="DevPollMultiView" ActiveViewIndex="0" runat="Server">
                <asp:View ID="Page1" runat="Server">
                    step1
                    <CuteWebUI:UploadAttachments ID="uploader1" runat="server">
                    </CuteWebUI:UploadAttachments>
                    <asp:Button ID="Page1Next" Text="Next" OnClick="NextButton_Command" runat="Server">
                    </asp:Button>
                </asp:View>
                <asp:View ID="Page2" runat="Server">
                    step2
                    <asp:Button ID="Page2Back" Text="Previous" OnClick="BackButton_Command" runat="Server">
                    </asp:Button>
                    <asp:Button ID="Page2Next" Text="Next" OnClick="NextButton_Command" runat="Server">
                    </asp:Button>
                </asp:View>
                <asp:View ID="Page3" runat="Server">
                    step3
                    <asp:Button ID="Page3Back" Text="Previous" OnClick="BackButton_Command" runat="Server">
                    </asp:Button>
                </asp:View>
            </asp:MultiView>
        </asp:Panel>
        </form>
    </body>
    </html>
     
    Regards,
     
    Ken 
View Complete Thread