User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 426,013 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,601 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 811 | Replies: 3 | Solved
Reply
Join Date: Jun 2008
Posts: 11
Reputation: Oreo1982 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Oreo1982 Oreo1982 is offline Offline
Newbie Poster

javascript alert not working right in asp.net

  #1  
Jul 18th, 2008
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
Last edited by Oreo1982 : Jul 18th, 2008 at 9:48 am.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2007
Posts: 257
Reputation: greeny_1984 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 10
greeny_1984's Avatar
greeny_1984 greeny_1984 is offline Offline
Posting Whiz in Training

Re: javascript alert not working right in asp.net

  #2  
Jul 19th, 2008
I too had the same problem.May be u have pop up blockers in the browser u are using.
Reply With Quote  
Join Date: Jun 2008
Posts: 11
Reputation: Oreo1982 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Oreo1982 Oreo1982 is offline Offline
Newbie Poster

Re: javascript alert not working right in asp.net

  #3  
Jul 21st, 2008
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?

Originally Posted by greeny_1984 View Post
I too had the same problem.May be u have pop up blockers in the browser u are using.
Reply With Quote  
Join Date: Jun 2008
Posts: 11
Reputation: Oreo1982 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Oreo1982 Oreo1982 is offline Offline
Newbie Poster

Re: javascript alert not working right in asp.net

  #4  
Jul 21st, 2008
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?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 1:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC