locked
Controlling sequential updatepanels RRS feed

  • Question

  • User615288127 posted

    I'm using Visual Studio 2015 with SQL Server 2014, VB.

    I have two updatepanels and I would like to find a way to execute the second as soon as the first is complete.  At the end of Button3_Click (first updatepanel) I have a line to start the second updatepanel, "Button4_Click( sender, e)" but it does not work.  Any suggestions?

    .aspx file

     
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="TestCprog2.aspx.vb" Inherits="TestCprog2" %>
    
    <%@ Import Namespace="System.Data"%>
    <%@ Import Namespace="System.Data.SqlClient"%>
    <%@ Import Namespace="System.Data.OleDb"%>
    <%@ Import Namespace="System.Web.Configuration"%>
    <%@ Import Namespace="System.Diagnostics"%>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
    
       Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            'Capacitors
            Comp = "Capacitors"
    
            --- SQL read/write operations ---
    
            Label1.Text = Cap & " Capacitors exported at " & DateTime.Now.ToString()
    
            Button4_Click(sender, e)
    
        End Sub
    
        Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            'Connectors
            Comp = "Connectors"
    
            --- SQL read/write operations ---
    
            Label2.Text = Con & " Connectors exported at " & DateTime.Now.ToString()
    
        End Sub
    
    
    
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
        <title></title>
    
    </head>
    <body style="width: 1446px">
    
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" AsyncPostBackTimeout="0">
            </asp:ScriptManager>
    
                <p style="font-family: 'Arial Black'; font-size: medium; font-weight: bold; font-style: normal">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Create Access copy for Home use</p>
                        <asp:Button ID="Button1" runat="server" 
                            Text="Generate Home Use Database" />
                        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" 
                            Text="Return to Main" /> &nbsp;
    
            <asp:Label ID="Label12" runat="server" Text="Capacitors"></asp:Label> &nbsp;
            <asp:Label ID="Label13" runat="server" Text="Connectors"></asp:Label>
    
     <asp:UpdatePanel ID="UpdatePanel1" runat="server" style="width:750px;" UpdateMode="Conditional">
                <ContentTemplate>
                    <fieldset style="width:750px;">
                        <asp:Button ID="Button3" runat="server" Text="Export" OnClick="Button3_Click" Style="width: 56px" /> &nbsp;        
                    <asp:Label ID="Label1" runat="server" Text="Capacitors"></asp:Label>
                        &nbsp;
                        <div style="display: inline-block">
                            <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
                                <ProgressTemplate>
                                    <script type="text/javascript">
                                        document.write("<div class='UpdateProgressBackground'></div>");</script>
                                    <span class="UpdateProgressContent"
                                        style="background-color: #FFFFFF; font-weight: bold; left: 572px; height: 29px;">Capacitor export in process...
                                <asp:Image ID="CapWaitCap" runat="server" ImageUrl="~/Images/progress.gif" />
                                    </span>
                                </ProgressTemplate>
                            </asp:UpdateProgress>
                        </div>
                    </fieldset>
                </ContentTemplate>
    </asp:UpdatePanel>
    
            <asp:UpdatePanel ID="UpdatePanel2" runat="server" style="width:750px;" UpdateMode="Conditional">
                <ContentTemplate>
                    <fieldset style="width:750px;">              
                    <asp:Button ID="Button4" runat="server" Text="Export" OnClick="Button4_Click" Style="width: 56px" /> &nbsp;              
                    <asp:Label ID="Label2" runat="server" Text="Connectors"></asp:Label>&nbsp;
                        <div style="display: inline-block">
                    <asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel2">
                        <ProgressTemplate>
                                <script type="text/javascript">
                                    document.write("<div class='UpdateProgressBackground'></div>");</script>
                                <span class="UpdateProgressContent"                                    
                                        style="background-color: #FFFFFF; font-weight: bold; left: 572px; height: 29px;">Connector export in process...
                                <asp:Image id="CapWaitCon" runat="server" ImageUrl="~/Images/progress.gif"/>
                                    </span>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                    </fieldset>
                </ContentTemplate>
            </asp:UpdatePanel>
            <br /> 
        </div>
        </form>
    </body>
    </html>
    

    Thursday, February 15, 2018 11:08 PM

All replies

  • User283571144 posted

    Hi Bulldog248,

    I have two updatepanels and I would like to find a way to execute the second as soon as the first is complete.  At the end of Button3_Click (first updatepanel) I have a line to start the second updatepanel, "Button4_Click( sender, e)" but it does not work.  Any suggestions?

    As far as I know, if you use updatepanel it will not update the whole page.

    It will only update the updatepanel part.

    So, if you fired the updatepanel1 button click event, it will not update the updatepanel2 content.

    I suggest you could try to use "UpdatePanel2.Update()" codes in the button click 4 event, then it will work well.

    Details codes as below:

        Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    
    
            Label1.Text = "aaa"
    
            Button4_Click(sender, e)
    
        End Sub
    
        Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            Label2.Text = "bbb"
            UpdatePanel2.Update()
        End Sub

    Result:

    Best Regards,

    Brando

    Friday, February 16, 2018 2:55 AM
  • User615288127 posted

    Hi Brando,

    This is getting close to what I want but not exactly.  Notice that at the end of each button_click the corresponding label gets updated.  This method updates both labels at the same time.  I want it to update label1, then go to updatepanel2 (and the corresponding updateprogress) then update the second label (label2).

    What I want seems to be a very difficult thing to accomplish but shouldn't be (to my line of thinking).  I have to believe others have tried to accomplish this and have a solution.  Maybe I'm overthinking it.

    Any more suggestions?

    Thanks!

    Friday, February 16, 2018 3:27 AM