This topic is locked

Event -Open a New Window with Error Message

6/29/2009 3:22:29 PM
ASPRunnerPro General questions
S
SDDivine author

I'm trying to prevent a duplicate entry of a user code so I'm using this code in the events on ASP. It works, but the error message that it produces is treated like a popup and most popup blockers prevent it being seen. Basically, I am trying to open a small window mid screen on top of the add form to say that you can't use that username, choose another one. Everything works except for the way this message is shown. Can someone please educate me as to how to make this appear without it being considered a pop up and then blocked. I would love for it to appear similar to the error messages already in ASPRunner that say certain fields are needed. Those popup's work, but I can't figure out how to write that code to do that.
Thanks

Steve Divine
This is my current code:
'** Check if specific record exists ****

strSQLExists = "select * from [master-list] where username='" & dict("username") &"'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if not rsExists.eof then

' if record exists do something
url = "error/user.htm"

response.write("<script>" & vbCrLf)

response.write("window.open('" & url & "');" & vbCrLf)

response.write("</script>")
BeforeAdd = False

else

' if dont exist do something else

dict("WhoUpdated")=Session("UserID")

BeforeAdd = True

end if

rsExists.Close : set rsExists = Nothing
End Function ' BeforeAdd

C
clig 6/30/2009

I'm trying to prevent a duplicate entry of a user code so I'm using this code in the events on ASP. It works, but the error message that it produces is treated like a popup and most popup blockers prevent it being seen. Basically, I am trying to open a small window mid screen on top of the add form to say that you can't use that username, choose another one. Everything works except for the way this message is shown. Can someone please educate me as to how to make this appear without it being considered a pop up and then blocked. I would love for it to appear similar to the error messages already in ASPRunner that say certain fields are needed. Those popup's work, but I can't figure out how to write that code to do that.

Thanks

Steve Divine
This is my current code:
'** Check if specific record exists ****

strSQLExists = "select * from [master-list] where username='" & dict("username") &"'"

set rsExists = CreateObject("ADODB.Recordset")

rsExists.Open strSQLExists, dbConnection
if not rsExists.eof then

' if record exists do something
url = "error/user.htm"

response.write("<script>" & vbCrLf)

response.write("window.open('" & url & "');" & vbCrLf)

response.write("</script>")
BeforeAdd = False

else

' if dont exist do something else

dict("WhoUpdated")=Session("UserID")

BeforeAdd = True

end if

rsExists.Close : set rsExists = Nothing
End Function ' BeforeAdd


Would this work with some modification such as capturing / defining an error condition?:
Response.Write "<script>alert('Name is taken please choose another')</script>"