hey folks,
I've got a problem. I created a function that creates a javascript alert. it works fine for the invalid date call, but not for the updated call. I have used this function on several other projects and have had no problems with it until now. If stepped through the debugger and it hits the call, it goes through the js function, but no alert comes up. any ideas?

Private Sub btnChg_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChg.Click
         Dim objEmployee As New Employee.Business.Employee(CInt(Request.QueryString("id")))
            Dim objemployee2 As New Employee.Business.Employee(cboSup.SelectedItem.Value)

                       
            If Not txtStartDate.Text = "" And Not txtStartDate.Text = " " Then
                If IsDate(txtStartDate.Text) Then
                    objEmployee.StartDate = txtStartDate.Text
                Else
                    scriptAlert("InvalidDate", "Start Date is Invalid")
                    Exit Sub
                End If
            Else
                objEmployee.StartDate = Null.NullDate
            End If
         'uneccesary code removed    

            If objEmployee.Update() Then
                scriptAlert("Updated", txtFName.Text + " " + txtLName.Text + "'s record has been updated.")
            Else
                scriptAlert("NotUpdated", txtFName.Text + " " + txtLName.Text + "'s record could not be updated.\nPlease check your values.")
            End If

            Response.Redirect("EmployeeListing.aspx")

        End Sub

function that creates js alert

Private Sub scriptAlert(ByVal key As String, ByVal message As String)
            Dim scriptKey As String = key
            Dim javaScript As String = "<script type='text/javascript' language=""JavaScript"">alert(""" + message + """);</script>"
            ClientScript.RegisterClientScriptBlock(Me.GetType(), scriptKey, javaScript)
        End Sub

Recommended Answers

All 3 Replies

I too had the same problem.May be u have pop up blockers in the browser u are using.

I wondered about that at first, but I've added other alerts to that same function that work properly. Pop up blockers wouldn't block one but not the other.. right? wouldn't they block all of them?

I too had the same problem.May be u have pop up blockers in the browser u are using.

I've figured out that is is the response.redirect that is causing the problem. as soon as i comment out that line. it works fine. I'm not sure why it is causing problems. I've tried server.transfer instead of response.redirect and it too prevents the alert from coming up. Any ideas on how to have that alert come up right before i go to the next page?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.