Quantcast
Channel: Visual Studio and Visual Web Developer Express
Viewing all articles
Browse latest Browse all 3509

Trouble executing multiple scripts, delay to allow first script to finish

$
0
0

I'm using Visual Web Developer 2010 Express with SQL Server 2008 Express, VB.

The sub below works but not as I would expect it to.  I would like for it to execute the first loop (open the new window, manipulate data, exit), if conditions exist, and then continue to the second loop (open the new window, manipulate data, exit), again, if conditions exist.  What actually happens is it executes the first loop (if conditions exist) and ends the sub.  If conditions for the first loop do not exist it executes the second loop and ends the sub.

It appears this has something to do with window.showModalDialog and when the window closes the routine ends.  Is there a way to open multiple windows before the routine ends?  Can some kind of delay be inserted between loops to wait for the first loop to complete?

    Protected Sub FormView1_ItemUpdating(sender As Object, e As System.Web.UI.WebControls.FormViewUpdateEventArgs) Handles FormView1.ItemUpdating

        Dim sqlConnection As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("conCString1").ConnectionString)
        Dim cmd As New SqlCommand
        cmd.CommandType = CommandType.Text
        cmd.Connection = sqlConnection
        Dim querystring As String = String.Empty
        Dim script As String = String.Empty
        Dim script1 As String = String.Empty
        Dim Prt As String = String.Empty
        Dim Fval As TextBox = FormView1.FindControl("PCB_FootprintTextBox")
        Dim Sval As TextBox = FormView1.FindControl("Schematic_PartTextBox")
        Dim X As Integer = 0
        Dim Y As Integer = 0
        Dim ReD As Boolean = False

        'Check footprints (loop 1)

        X = InStr(Fval.Text, ",")
        If X = 0 Then
            querystring = "SELECT [Footprint] FROM [Combined Footprints] WHERE ([Footprint] = '" & Fval.Text & "')"
            sqlConnection.Open()
            Dim command As New SqlCommand(querystring, sqlConnection)
            Dim reader As SqlDataReader = command.ExecuteReader()
            While reader.Read()
                Prt = reader(0).ToString
            End While
            sqlConnection.Close()
            If Prt <> Fval.Text Then    'Verify user wants new footprint or oopsed and offer list of similarities
                ParamA = Fval.Text
                MyArgs = ParamA
                Session("FPT") = MyArgs.ToString
                script = "window.showModalDialog('Footprints.aspx', '" & MyArgs & "','height=800,width=800', 'scrollbars=yes');"
                ScriptManager.RegisterStartupScript(Me, Me.GetType(), "popup", script, True)
                ReD = True
            End If
            If Prt = Fval.Text Then     'Footprint exists so continue to itemupdated/inserted
            End If
        End If
        If X <> 0 Then
            'later
        End If
        '
        'Check schematic symbols (loop 2)
        '
        Y = InStr(Sval.Text, ",")
        If Y = 0 Then
            querystring = "SELECT [Symbol] FROM [Combined Symbols] WHERE ([Symbol] = '" & Sval.Text & "')"
            sqlConnection.Open()
            Dim command As New SqlCommand(querystring, sqlConnection)
            Dim reader As SqlDataReader = command.ExecuteReader()
            While reader.Read()
                Prt = reader(0).ToString
            End While
            sqlConnection.Close()
            If Prt <> Sval.Text Then    'Verify user wants new symbol or oopsed and offer list of similarities
                ParamA = Sval.Text
                MyArgs = ParamA
                Session("SPT") = MyArgs.ToString
                script1 = "window.showModalDialog('Symbols.aspx', '" & MyArgs & "','height=800,width=800', 'scrollbars=yes');"
                ScriptManager.RegisterStartupScript(Me, Me.GetType(), "popup", script1, True)
                ReD = True
            End If
            If Prt = Sval.Text Then     'Symbol exists so continue to itemupdated/inserted
            End If
        End If
        If Y <> 0 Then
            'later
        End If
        If ReD = True Then e.Cancel = True

    End Sub

Thanks!


Viewing all articles
Browse latest Browse all 3509

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>