troubleshooting Question

JavaScript doesnt execute before code finishes

Avatar of mgmhicks
mgmhicks asked on
JavaScript.NET ProgrammingVisual Basic.NET
6 Comments2 Solutions360 ViewsLast Modified:
I have a page that loads checks for a session variable and responds in the following way

Master.myTitle = "Inspection Charges Report"
                    GetDates()
                    If IsDate(hfBeginDate.Value) Then
                        If IsDate(hfBeginDate.Value) Then
                            If InspectionChargesReport() Then
                            Else

                            End If

                        Else

                        End If
                    Else
                        ClientScript.RegisterClientScriptBlock(Me.GetType(), "ClientScript", "alert ('Invalid Begin Date') ", True)
                    End If

 Private Sub GetDates()

        Page.ClientScript.RegisterStartupScript(Me.GetType(), "Script", "jsInputBox();", True)

    End Sub

So what I dont understand and what is happening is that the code continues after getdates() sub, before the actual javascript has done its function, which is to bring up 2 prompt boxes asking for the dates.  How do I change my code to make it react the way I want and thats to get the dates before continuing.  My issue is that I want to run a report that takes 2 variable and begin and enddate and I have to ask user for those dates before continuing.  I really dont want to create a form just to enter 2 dates.  The javascript program attached does work correctly, just not triggering when I need it to.

 function jsInputBox() {
        var mBegin = prompt("Enter Begin Date", "");
        //  return (mBegin);
        var newBegin = document.getElementById("ctl00_ContentPlaceHolder1_hfBeginDate");
        newBegin.value = mBegin;
        //var txtCont = document.getElementById('<%= Page.FindControl("ContentPlaceHolder1").FindControl("txtContent").ClientID %>');
        var mEnd = prompt("Enter End Date:", "");
        //  return (mEnd);
        var newEnd = document.getElementById("ctl00_ContentPlaceHolder1_hfEndDate");
        newEnd.value = mEnd;
       
    }




thanks
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros