popupscripts
I'm having a little issue with my pop ups. I have several buttons on my application that displays calendars in popupwindows. When I push the calendar button that's at the beginnig of my application my validation summary and all validators appear and I can't enter that particular date until I've entered in all other data. Does anyone know where this is stemming from? here's the code...
Dim popupScript As String = "<script language='javascript'>" & _
"window.open('calendar.aspx?formname=frmFireworksP ermitApp.txtdisplaydate', 'calendar', " & _
"'width = 300, height = 200, menubar = no, resizable=yes, scroll=auto');my_window.focus()" & _
"</script>"
Dim popupScript2 As String = "<script language='javascript'>" & _
"window.open('calendar.aspx?formname=frmFireworksP ermitApp.txtddate', 'calendar', " & _
"'width = 300, height = 200, menubar = no, resizable=yes, scroll=auto');my_window.focus()" & _
"</script>"
Dim popupScript3 As String = "<script language='javascript'>" & _
"window.open('calendar.aspx?formname=frmFireworksP ermitApp.txtrdate', 'calendar', " & _
"'width = 300, height = 200, menubar = no, resizable=yes, scroll=auto');my_window.focus()" & _
"</script>"
Dim popupScript4 As String = "<script language='javascript'>" & _
"window.open('calendar.aspx?formname=frmFireworksP ermitApp.txtreadystand', 'calendar', " & _
"'width = 300, height = 200, menubar = no, resizable=yes, scroll=auto');my_window.focus()" & _
"</script>"
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Production connection
Dim DBConn As New SqlConnection(Application("DBConn")) 'Open a new connection
If Not IsPostBack Then
Dim objCommand As New SqlCommand("spSelectStates", DBConn)
'Declare command that calls stored proc that retrieves the list of the states
objCommand.CommandType = CommandType.StoredProcedure
Dim adapter As New SqlDataAdapter(objCommand)
Dim dsStates As New DataSet
'Load all the state listboxes with the list of states
Try
DBConn.Open() 'Open the connection
adapter.Fill(dsStates)
DBConn.Close() 'Close the connection
lstMailingState.DataSource = dsStates
lstMailingState.DataBind() 'Bind the list of the states to the state's listbox
lstMailingState.Items.Insert(0, "Select State")
lstMailingState.Items.Item(0).Value = ""
lstBusState.DataSource = dsStates
lstBusState.DataBind()
lstBusState.Items.Insert(0, "Select State")
lstBusState.Items.Item(0).Value = ""
lstPurchaseCoState.DataSource = dsStates
lstPurchaseCoState.DataBind()
lstPurchaseCoState.Items.Insert(0, "Select State")
lstPurchaseCoState.Items.Item(0).Value = ""
Catch excep As Exception
Response.Write("<script language=javascript>alert(""Errors Encountered While Loading States into State Listboxes!"");</script>")
End Try
Dim Command As New SqlCommand("spSelectCounties", DBConn)
'Declare command that calls stored proc that retrieves the list of the counties
Command.CommandType = CommandType.StoredProcedure
Dim objReader As SqlDataReader
Try
DBConn.Open() 'Open the connection
objReader = Command.ExecuteReader() 'Execute the stored proc
lstBusCounty.DataSource = objReader
lstBusCounty.DataBind() 'Bind the list of the counties to the counties' listbox
lstBusCounty.Items.Insert(0, "Select County")
lstBusCounty.Items.Item(0).Value = ""
objReader.Close()
DBConn.Close() 'Close the connection
Catch excep As Exception
Response.Write("<script language=javascript>alert(""Errors Encountered While Loading Counties into County Listbox!"");</script>")
End Try
End If
End Sub
Private Sub btnContinue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
'User has decided to complete another application
'Call subproc that assigns user id and transaction number if not already assigned
AssignID()
'Call subproc that validates form
ChkForm()
If intCountErrors = 0 Then 'If no errors found then....
'Check for duplicate
CheckDuplicate()
If intCount = 0 Then 'not a duplicate
'Insert info into temp tables
InsertTempTables()
Session("TransactionNumber") = ""
If CheckTransactionCount() < 25 Then
'Clear form so user can complete another application
Response.Redirect("Default.aspx")
Else
'Direct user to E-Signature page because they have reached their max limit on transactions for this session
'Create session variable for ESignature page to use to tell user that they have completed max number of applications for this session
Session("MaxLimit") = "Max"
Response.Redirect("ESignature.aspx")
End If
Else
'if it's a Duplicate
Session("TransactionNumber") = ""
Response.Redirect("Stop.aspx")
End If
End If
End Sub
Sub ChkForm()
'Sub proc that validates form completion
intCountErrors = 0
Dim strBusPhone As String
Dim strHomePhone As String
Dim strPurchaseCoPhone As String
Dim strDOB As String
Dim strSSN As String
strBusPhone = txtBusPhone1.Value + txtBusPhone2.Value + txtBusPhone3.Value
strHomePhone = txtHomePhone1.Value + txtHomePhone2.Value + txtHomePhone3.Value
strDOB = txtDOB1.Value + "/" + txtDOB2.Value + "/" + txtDOB3.Value
strSSN = txtSSN1.Value + txtSSN2.Value + txtSSN3.Value
strPurchaseCoPhone = txtPurchaseCoPhone1.Value + txtPurchaseCoPhone2.Value + txtPurchaseCoPhone3.Value
'If Len(strReadyDate) <> "10" Or IsDate(strReadyDate) = False Then
' intCountErrors += 1
' Response.Write("<script language=javascript>alert(""Invalid Date Stand Will Be Ready On Site! Must be in format MM/DD/YYYY."");</script>")
' SetInitialFocus(txtReadyMonth)
' Exit Sub
'Else
'End If
If ddlFWClass.SelectedItem.Value = "R" Or ddlFWClass.SelectedItem.Value = "SR1" Or ddlFWClass.SelectedItem.Value = "SR2" Then
If txtSalesTaxNo.Text = "" Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""State Sales Tax Number Required!"");</script>")
SetInitialFocus(txtSalesTaxNo)
Exit Sub
End If
End If
If strSSN <> "" Then
If Len(strSSN) <> "9" Or IsNumeric(strSSN) = False Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Invalid Social Security Number!"");</script>")
SetInitialFocus(txtSSN1)
Exit Sub
End If
Else
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Social Security Number is Required!"");</script>")
SetInitialFocus(txtSSN1)
Exit Sub
End If
If Len(strDOB) <> "10" Or IsDate(strDOB) = False Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Invalid Date of Birth! Must be in format MM/DD/YYYY."");</script>")
SetInitialFocus(txtDOB1)
Exit Sub
End If
If Len(strHomePhone) <> "10" Or IsNumeric(strHomePhone) = False Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Invalid Home Phone Number!"");</script>")
SetInitialFocus(txtHomePhone1)
Exit Sub
End If
If Len(strBusPhone) <> "10" Or IsNumeric(strBusPhone) = False Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Invalid Work Phone Number!"");</script>")
SetInitialFocus(txtBusPhone1)
Exit Sub
End If
If lstMailingState.SelectedItem.Value = "" Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""You must select a state for your mailing address!"");</script>")
SetInitialFocus(lstMailingState)
Exit Sub
End If
If zipcode(txtMailingZip.Text) = False Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Invalid Mailing Zip Code!"");</script>")
SetInitialFocus(txtMailingZip)
Exit Sub
End If
If lstBusState.SelectedItem.Value = "" Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""You must select a state for your business address!"");</script>")
SetInitialFocus(lstBusState)
Exit Sub
End If
If lstBusCounty.SelectedItem.Value = "" Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""You must select a county for your business address!"");</script>")
SetInitialFocus(lstBusCounty)
Exit Sub
End If
If lstPurchaseCoState.SelectedItem.Value = "" Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""You must select a state for your purchase company's address!"");</script>")
SetInitialFocus(lstPurchaseCoState)
Exit Sub
End If
If zipcode(txtPurchaseCoZip.Text) = False Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Invalid Purchase Company Zip Code!"");</script>")
SetInitialFocus(txtPurchaseCoZip)
Exit Sub
End If
If Len(strPurchaseCoPhone) <> "10" Or IsNumeric(strPurchaseCoPhone) = False Then
intCountErrors += 1
Response.Write("<script language=javascript>alert(""Invalid Purchase Company Phone Number!"");</script>")
SetInitialFocus(txtPurchaseCoPhone1)
Exit Sub
End If
End Sub
Sub CheckDuplicate()
'Sub proc that checks to see if permit has already been applied for
'Production connection
Dim DBConn As New SqlConnection(Application("DBConn")) 'Open a new connection
Dim cmdChkDuplicate As New SqlCommand("spCheckTempFWPermitDuplicate", DBConn)
cmdChkDuplicate.CommandType = CommandType.StoredProcedure
'Stored proc checks to see if current user has already applied for this permit during this transaction
'Declare parameters to send to the stored proc
Dim prmCompanyName As New SqlParameter("@vchCompanyName", SqlDbType.VarChar)
prmCompanyName.Value = Trim(txtBusinessName.Text)
cmdChkDuplicate.Parameters.Add(prmCompanyName)
Dim prmCompanyAdd1 As New SqlParameter("@vchCompanyAddress1", SqlDbType.VarChar)
prmCompanyAdd1.Value = Trim(txtBusAddress1.Text)
cmdChkDuplicate.Parameters.Add(prmCompanyAdd1)
Dim prmUserID As New SqlParameter("@vchFWUserID", SqlDbType.VarChar)
prmUserID.Value = Session("FWUserID")
cmdChkDuplicate.Parameters.Add(prmUserID)
Dim prmFWClass As New SqlParameter("@vchFWClass", SqlDbType.VarChar)
prmFWClass.Value = ddlFWClass.SelectedItem.Value
cmdChkDuplicate.Parameters.Add(prmFWClass)
Dim objDataReader As SqlDataReader
DBConn.Open()
objDataReader = cmdChkDuplicate.ExecuteReader()
Do While objDataReader.Read()
intCount += 1
Loop
objDataReader.Close()
DBConn.Close()
If intCount = 0 Then
'Check to see if permit has already been applied for in another transaction
Dim strCheckDuplicate2 As String
strCheckDuplicate2 = "spCheckFWPermitDuplicate"
Dim objCheckDuplicate2 As New SqlCommand(strCheckDuplicate2, DBConn)
Dim objDataReader2 As SqlDataReader
objCheckDuplicate2.CommandType = CommandType.StoredProcedure
'Declare parameter to send to the stored procedure.
Dim prmCompanyName2 As New SqlParameter("@vchCompanyName", SqlDbType.VarChar)
prmCompanyName2.Value = Trim(txtBusinessName.Text)
objCheckDuplicate2.Parameters.Add(prmCompanyName2)
Dim prmCompanyAddress1 As New SqlParameter("@vchCompanyAddress1", SqlDbType.VarChar)
prmCompanyAddress1.Value = Trim(txtBusAddress1.Text)
objCheckDuplicate2.Parameters.Add(prmCompanyAddres s1)
Dim prmFWClass2 As New SqlParameter("@vchFWClass", SqlDbType.VarChar)
prmFWClass2.Value = ddlFWClass.SelectedItem.Value
objCheckDuplicate2.Parameters.Add(prmFWClass2)
DBConn.Open()
objDataReader2 = objCheckDuplicate2.ExecuteReader()
Do While objDataReader2.Read()
intCount += 1
Loop
objDataReader2.Close()
DBConn.Close()
End If
End Sub
Sub InsertTempTables()
'Sub proc that inserts info into temp tables
'Production connection
Dim DBConn As New SqlConnection(Application("DBConn")) 'Open a new connection
Dim cmdInsertTempTables As New SqlCommand("spInsertTempFWPermitTables", DBConn)
Dim sqldatenull As SqlDateTime
sqldatenull = SqlDateTime.Null
cmdInsertTempTables.CommandType = CommandType.StoredProcedure
'Stored proc that inserts record into temp tables
If lstApplicantMI.SelectedItem.Value = "Select" Then
lstApplicantMI.SelectedItem.Value = ""
End If
Try
strrdate = txtrdate.text
strddate = txtddate.text
strdisplaydate = txtdisplaydate.text
strlname = txtApplicantLastName.Text
strfname = txtApplicantFirstName.Text
strMI = lstApplicantMI.SelectedItem.Value
strhomeph = txtHomePhone1.Value + txtHomePhone2.Value + txtHomePhone3.Value
strworkph = txtBusPhone1.Value + txtBusPhone2.Value + txtBusPhone3.Value
strPCPhone = txtPurchaseCoPhone1.Value + txtPurchaseCoPhone2.Value + txtPurchaseCoPhone3.Value
dtdob = txtDOB1.Value + "/" + txtDOB2.Value + "/" + txtDOB3.Value
strReadyDate = txtreadystand.Text
strSSN = txtSSN1.Value + txtSSN2.Value + txtSSN3.Value
strAddr1 = txtMailingAddress1.Text
strAddr2 = txtMailingAddress2.Text
strCity = txtMailingCity.Text
strState = lstMailingState.SelectedItem.Value
strZip = txtMailingZip.Text
strConame = txtBusinessName.Text
strCoAddr1 = txtBusAddress1.Text
strCoAddr2 = txtBusAddress2.Text
strCoCity = txtBusCity.Text
strCostate = lstBusState.SelectedItem.Value
strCoCounty = lstBusCounty.SelectedItem.Value
strClass = ddlFWClass.SelectedItem.Value
strSalesID = txtSalesTaxNo.Text
strPCName = txtPurchaseCoName.Text
strPCAddr1 = txtPurchaseCoAddress1.Text
strPCaddr2 = txtPurchaseCoAddress2.Text
strPCCity = txtPurchaseCoCity.Text
strPCState = lstPurchaseCoState.SelectedItem.Value
strPCZip = txtPurchaseCoZip.Text
strrtime = txtrtime.Text
strdtime = txtdtime.Text
strdisplaytime = txtdisplaytime.Text
strsponsor = txtsponsor.Text
strconductor = txtconductor.Text
strtodaydate = txttodaydate.Text
strFWUserID = Session("FWUserID")
strTransactionNumber = Session("TransactionNumber")
DBConn.Open()
With cmdInsertTempTables.Parameters
.Add("@vchmiddleInitial", strMI)
.Add("@vchLastname", strlname)
.Add("@vchfirstname", strfname)
.Add("@dtdob", dtdob)
.Add("@vchSSN", strSSN)
.Add("@vchApplicantAddress1", strAddr1)
.Add("@vchApplicantCity", strCity)
.Add("@vchApplicantState", strState)
.Add("@vchApplicantZip", strZip)
.Add("@vchApplicantHomePhone", strhomeph)
.Add("@vchApplicantWorkPhone", strworkph)
.Add("@vchcompanyname", strConame)
.Add("@vchcompanyaddress1", strCoAddr1)
.Add("@vchcompanycity", strCoCity)
.Add("@vchcompanystate", strCostate)
.Add("@vchcounty", strCoCounty)
.Add("@vchFWClass", strClass)
.Add("@vchSalesID", strSalesID)
.Add("@vchFWUserID", strFWUserID)
.Add("@vchTransactionNumber", strTransactionNumber)
.Add("@vchPurCoName", strPCName)
.Add("@vchPurcoaddress1", strPCAddr1)
.Add("@vchPurcocity", strPCCity)
.Add("@vchPurcoState", strPCState)
.Add("@vchPurcoZip", strPCZip)
.Add("@vchPurcophone", strPCPhone)
If txttodaydate.Text = "" Then
.Add("@dtentered", sqldatenull)
Else
.Add("@dtentered", txttodaydate.Text)
End If
If strrdate = "" Then
.Add("@dtrdate", sqldatenull)
Else
.Add("@dtrdate", CDate(strrdate))
End If
If strReadyDate = "" Then
.Add("@dtStandReadyDate", sqldatenull)
Else
.Add("@dtStandReadyDate", CDate(strReadyDate))
End If
If strdisplaydate = "" Then
.Add("@dtdisplaydate", sqldatenull)
Else
.Add("@dtdisplaydate", CDate(strdisplaydate))
End If
If strddate = "" Then
.Add("@dtddate", sqldatenull)
Else
.Add("@dtddate", CDate(strddate))
End If
If strReason = "" Then
.Add("@vchApplicationReason", "")
Else
.Add("@vchApplicationReason", strReason)
End If
If strrtime = "" Then
.Add("@vchrtime", sqldatenull)
Else
.Add("@vchrtime", strrtime)
End If
If strdtime = "" Then
.Add("@vchdtime", sqldatenull)
Else
.Add("@vchdtime", strdtime)
End If
If strdisplaytime = "" Then
.Add("@vchdisplaytime", sqldatenull)
Else
.Add("@vchdisplaytime", strdisplaytime)
End If
If strsponsor = "" Then
.Add("@vchsponsor", sqldatenull)
Else
.Add("@vchsponsor", strsponsor)
End If
If strconductor = "" Then
.Add("@vchconductor", sqldatenull)
Else
.Add("@vchconductor", strconductor)
End If
If strAddr2 = "" Then
.Add("@vchApplicantAddress2", sqldatenull)
Else
.Add("@vchApplicantAddress2", strAddr2)
End If
If strCoAddr2 = "" Then
.Add("@vchcompanyaddress2", sqldatenull)
Else
.Add("@vchcompanyaddress2", strCoAddr2)
End If
If strPCaddr2 = "" Then
.Add("@vchPurcoaddress2", sqldatenull)
Else
.Add("@vchPurcoaddress2", strPCaddr2)
End If
Dim strAmount As String
Dim NumDays As Long
Select Case ddlFWClass.SelectedItem.Value
Case "PD"
NumDays = DateDiff("d", CDate(strtodaydate), CDate(strddate))
If NumDays < 10 Then
strAmount = 100
Else
strAmount = 50
End If
Case "CP"
NumDays = DateDiff("d", CDate(strtodaydate), CDate(strdisplaydate))
If NumDays < 10 Then
strAmount = 200
Else
strAmount = 100
End If
Case Else
End Select
If ddlFWClass.SelectedItem.Value = "D" Then
strAmount = 2000
End If
If ddlFWClass.SelectedItem.Value = "M" Then
strAmount = 2000
End If
If ddlFWClass.SelectedItem.Value = "R" Then
strAmount = 200
End If
If ddlFWClass.SelectedItem.Value = "W" Then
strAmount = 700
End If
If ddlFWClass.SelectedItem.Value = "SR1" Then
strAmount = 100
End If
If ddlFWClass.SelectedItem.Value = "SR2" Then
strAmount = 200
End If
.Add("@mAmount", CDbl(strAmount))
End With
cmdInsertTempTables.ExecuteNonQuery()
DBConn.Close()
Catch er As Exception
LogError(er.ToString, "Application")
Exit Try
Finally
DBConn.Close()
End Try
End Sub
Public Function zipcode(ByRef strZipCode As String) As Boolean
'Function that validates zip code entered by user
'Returns True if the zip code is valid
strZipCode = Trim$(strZipCode)
Return Regex.IsMatch(strZipCode, "^\d{5}(-?\d{4})?$")
End Function
Function CheckTransactionCount()
'Counts number of applications this user has completed so far
Dim DBConn As New SqlConnection(Application("DBConn")) 'Open a new connection
Dim objCommand As New SqlCommand("SELECT Count(*) As Count FROM tblTempOnlineFWTransactions WHERE vchFWUserID = @vchFWUserID", DBConn)
Dim objDataReader As SqlDataReader
Dim intCountTrans As Integer
'Declare parameter to send to the stored procedure.
Dim prmUserID As New SqlParameter("@vchFWUserID", SqlDbType.VarChar)
prmUserID.Value = Session("FWUserID")
objCommand.Parameters.Add(prmUserID)
DBConn.Open()
objDataReader = objCommand.ExecuteReader()
Do While objDataReader.Read()
intCountTrans = objDataReader("Count")
Loop
objDataReader.Close()
DBConn.Close()
Return intCountTrans
End Function
Private Sub btnFinish_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFinish.Click
'User does not want to complete another application
'User wants to finish transaction and pay
'Call subproc that assigns user ID and transaction number if not already assigned
AssignID()
'Call subproc that validates form
ChkForm()
If intCountErrors = 0 Then
'Check for Duplicate
CheckDuplicate()
If intCount = 0 Then
'Insert info into temp tables
InsertTempTables()
If ddlFWClass.SelectedItem.Value = "PD" Then
'Transfer to finished application
Response.Redirect("PD.aspx")
Else
If ddlFWClass.SelectedItem.Value = "CP" Then
'Transfer to checklist
Response.Redirect("\\iddevelop\FireworksPermitApp\ CloseProximatechecklist.pdf") 'Open on iddevelop
'Response.Redirect("\\idappsrvr01\FireworksPermitA pp\CloseProximatechecklist.pdf") 'Open on idappsrvr01
Else
'Transfer to E-Signature page
Response.Redirect("ESignature.aspx")
End If
End If
Else 'if it's a duplicate
Session("TransactionNumber") = ""
Response.Redirect("Stop.aspx")
End If
End If
End Sub
Sub AssignID()
Dim DBConn As New SqlConnection(Application("DBConn")) 'Open a new connection
'Assign unique UserID if not already assigned
If Session("FWUserID") = "" Then
Dim strGetFWUserID As String
strGetFWUserID = "spGetFWUserID"
'Stored proc that gets the next incremented FWUserID value
Dim objGetUserID As New SqlCommand(strGetFWUserID, DBConn)
Dim objRead As SqlDataReader
objGetUserID.CommandType = CommandType.StoredProcedure
DBConn.Open()
objRead = objGetUserID.ExecuteReader()
Do While objRead.Read()
Session("FWUserID") = objRead("FWUserID")
Loop
objRead.Close()
DBConn.Close()
End If
'Assign transaction number if not already assigned
If Session("TransactionNumber") = "" Then
Dim strGetFWTransNumber As String
Dim strYear As String
strYear = Year(Now())
strGetFWTransNumber = "spGetFWTransNumber"
'Stored proc that gets the next incremented FW transaction number value
Dim objGetFWTransNumber As New SqlCommand(strGetFWTransNumber, DBConn)
Dim Read As SqlDataReader
Dim strTransactionNumber As String
objGetFWTransNumber.CommandType = CommandType.StoredProcedure
DBConn.Open()
Read = objGetFWTransNumber.ExecuteReader()
Do While Read.Read()
strTransactionNumber = Read("FWTransactionNumber")
Loop
Read.Close()
DBConn.Close()
Session("TransactionNumber") = strYear + "-" + strTransactionNumber
End If
End Sub
Public Shared Sub SetInitialFocus(ByVal ctrl As Control)
'Sub proc that sets the focus on a selected control
&nb
|