pradyun123
Posts: 8
|
Posted: 06/08/2007, 9:43 AM |
|
hi! every body
plz anyone help me out
iam trying to display a message box before i insert data into data base
in asp
first of all how to write messagebox in response.write
if the condition meets a message box should be displayed or else data should be inserted into database
bye
_________________
asp,ado's |
|
|
smalloy
Posts: 107
|
Posted: 06/08/2007, 10:12 AM |
|
An age old quetion my friend! The answer is you can't, sort of. To do this you will need JavaScript which could be a tad difficult if you are new to it. Let me know if you need the code and I'll write something in Javascript.
But since you are doing his before you insert data you have some options, Onvalidate is a perfect candidate to display an custom error to the user, here is my example:
'Rule 1 Owner is required
If Len(autos.Owner_ID.Value) < 1 Then
autos.Errors.addError("Vehicle Owner is Required")
End if
It is used like this: the record(or orid).Errors.adderror("custom error message"), you clould also do a redirect to a page with an error message displayed too.
Steve
_________________
Anything can be done, just give me time and money. |
|
|
pradyun123
Posts: 8
|
Posted: 06/08/2007, 11:03 AM |
|
Hi!
actually iam creating user name and passwords. so first name , last name , initial and password.
initial should be only one character and password should be only 6 characters and only lower case letters. so i hv taken length of the password and initial if
initial >1 or password >6 then a message box should be displayed and the message would be "Plz enter one char for initial and 6 char for password". if the if condition fails then data should be inserted into database . iam using msaccess database. and i hv mentioned to initial field max length 1 and password 6. when iam trying to insert data for inital more than 1 char it is showing that error that is
"The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data."
but i am not able to display message box what should i do
and first of all how to write message box in asp it is giivingerror permissions denied if i write like this
response.write("<" & script=language vbscript>")
response.write("msgbox"""& msg &""" & vbCrlf ")
response.write("</script>")
plz tell me some solution my project has been hanged up here
_________________
asp,ado's |
|
|
smalloy
Posts: 107
|
Posted: 06/08/2007, 12:10 PM |
|
Here is the code, it will work, I promise!
Dim strRefresh
Dim strErrorMessage
strErrorMessage = “"The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data."”
strRefresh= "<script language=javascript>"
strRefresh=strRefresh & " alert(' & strErrorMessage & ' );"
strRefresh=strRefresh & " </script>"
Response.Write(strRefresh)
Response.end
Feel free to play with it BUT remember that JavaScript is case sensitive!!!!
Steve
_________________
Anything can be done, just give me time and money. |
|
|
pradyun123
Posts: 8
|
Posted: 06/08/2007, 7:32 PM |
|
hi!
thank u i solved it.
u did a grt job and it worked out.
thanks a lot
bye.
radha manohari
_________________
asp,ado's |
|
|
|