allday
asked on
attributes onclick is not working
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
Me.btn1.Attributes("onClic k") = "javascript:return " & _
"confirm('Are you sure you want to delete?'). " & ""
End Sub
what im doing wrong here?
when the user clicks on the button i want to display the message
Me.btn1.Attributes("onClic
"confirm('Are you sure you want to delete?'). " & ""
End Sub
what im doing wrong here?
when the user clicks on the button i want to display the message
Hi,
try this
btn1.Attributes.Add("oncli ck", "return confirm('Are you sure you want to delete?');")
ayha
try this
btn1.Attributes.Add("oncli
ayha
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
if you do not put inside the page_load then you have to click twice to get the message i guess first time when you click it will initilize and second time it fires
so the solution of blxml2 was correct :)
so the solution of blxml2 was correct :)
ASKER
oh shoot i forgot to ask
the main thing......
if the user click ok how should i know if the user click ok or cancel ?
and how to i trap that and run condition based on that?
the main thing......
if the user click ok how should i know if the user click ok or cancel ?
and how to i trap that and run condition based on that?
if the user clicks ok, the postback occurs. If the user clicks cancel, the postback does not occur.
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
'do your stuff for deletion
End Sub
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
'do your stuff for deletion
End Sub
ASKER
you saying its safe?
it safe to write delete commands without writing any condtional statements?
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
'do your stuff for deletion
'it safe to write delete commands without writing any condtional statements?
End Sub
it safe to write delete commands without writing any condtional statements?
Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click
'do your stuff for deletion
'it safe to write delete commands without writing any condtional statements?
End Sub
You asked this: "if the user click ok how should i know if the user click ok or cancel"
I responded: " if the user clicks ok, the postback occurs. If the user clicks cancel, the postback does not occur."
No one mentioned the word safe. Therefore, do not put words in my mouth. You can of course quote what I have stated.
To make it safe, you have to include the scenario where Javascript is disabled as well as checking to see if the page is valid (with all validations passed) plus with any added business logic.
I responded: " if the user clicks ok, the postback occurs. If the user clicks cancel, the postback does not occur."
No one mentioned the word safe. Therefore, do not put words in my mouth. You can of course quote what I have stated.
To make it safe, you have to include the scenario where Javascript is disabled as well as checking to see if the page is valid (with all validations passed) plus with any added business logic.
ASKER
can you please look at this
btnDelete.Attributes("onCl ick") = "javascript:return " & _
"confirm('Are you sure you want to delete ID: '" _
& Me.txtID.Text & "' from Master?')"
im getting stupid error message in javascript and the error is:
Error: Expected ')'
btnDelete.Attributes("onCl
"confirm('Are you sure you want to delete ID: '" _
& Me.txtID.Text & "' from Master?')"
im getting stupid error message in javascript and the error is:
Error: Expected ')'
Me.btn1.Attributes("onClic