Hi,
I have created an alert message that displays as a pop-up window that is supposed to display whenever an error is encountered - I call it in the catch block of my try-catch. (Previously I was using a label on the page and setting it's text value to the error message and changing it's visible property from true to false whenever an error was encountered.) I changed to this much cleaner, better looking option.
My problem is that, when I call it, it displays sometimes and sometimes it doesn't...I don't know why. On the pages where it displays fine, it always works, but on other pages, under other unknown conditions, it never works. If anyone could shed some light, I would appreciate it VERY much. I've put this code in A LOT of pages of my web application, changing over from the label method...it worked in the page I first changed and tested so I made the mass changes...now it's not working in some instances. ??? Below is the code I'm using...
Thanks in advance,
Sue
Try
InsertSql = "Insert into AuthorizedCentralUsers (UserName,MaintOrgData,MaintAgncyData,MaintAccrdtrData,MaintItmDescData,DelAccrdLstRec,MaintUserData,MaintLaptopUserData,MaintSchoolCodeData,MaintComponentData,MaintProponentData,Reports,Password) values('" & UserName & "','" & MaintOrg & "','" & MaintAgncy & "','" & MaintAccrdtr & "','" & MaintDesc & "','" & DelASLRec & "','" & MaintCenUser & "','" & MaintLaptopUser & "','" & MaintSC & "','" & MaintComp & "','" & MaintProp & "','" & Rpts & "','" & HashedPassword & "')"
MyInsertCmd = New SqlClient.SqlCommand(InsertSql, DBConn)
DBConn.Open()
MyInsertCmd.ExecuteNonQuery()
'ASPNET_MsgBox("User record added successfully.")
ViewState("MainRecDone") = 1
Catch exc As Exception
WriteError = True
ASPNET_MsgBox("ERROR SAVING NEW RECORD >>> (" & exc.Message & ")")
End Try
Public Sub ASPNET_MsgBox(ByVal Message As String)
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert(""" & Message & """)" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
End Sub
I have created an alert message that displays as a pop-up window that is supposed to display whenever an error is encountered - I call it in the catch block of my try-catch. (Previously I was using a label on the page and setting it's text value to the error message and changing it's visible property from true to false whenever an error was encountered.) I changed to this much cleaner, better looking option.
My problem is that, when I call it, it displays sometimes and sometimes it doesn't...I don't know why. On the pages where it displays fine, it always works, but on other pages, under other unknown conditions, it never works. If anyone could shed some light, I would appreciate it VERY much. I've put this code in A LOT of pages of my web application, changing over from the label method...it worked in the page I first changed and tested so I made the mass changes...now it's not working in some instances. ??? Below is the code I'm using...
Thanks in advance,
Sue
Try
InsertSql = "Insert into AuthorizedCentralUsers (UserName,MaintOrgData,MaintAgncyData,MaintAccrdtrData,MaintItmDescData,DelAccrdLstRec,MaintUserData,MaintLaptopUserData,MaintSchoolCodeData,MaintComponentData,MaintProponentData,Reports,Password) values('" & UserName & "','" & MaintOrg & "','" & MaintAgncy & "','" & MaintAccrdtr & "','" & MaintDesc & "','" & DelASLRec & "','" & MaintCenUser & "','" & MaintLaptopUser & "','" & MaintSC & "','" & MaintComp & "','" & MaintProp & "','" & Rpts & "','" & HashedPassword & "')"
MyInsertCmd = New SqlClient.SqlCommand(InsertSql, DBConn)
DBConn.Open()
MyInsertCmd.ExecuteNonQuery()
'ASPNET_MsgBox("User record added successfully.")
ViewState("MainRecDone") = 1
Catch exc As Exception
WriteError = True
ASPNET_MsgBox("ERROR SAVING NEW RECORD >>> (" & exc.Message & ")")
End Try
Public Sub ASPNET_MsgBox(ByVal Message As String)
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("alert(""" & Message & """)" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
End Sub