Urgent~ Please help to have Message Box with yes/no buttons


J

JenHu

Hi experts,

In my asp.net application, I use VB.NET code. I want to have a
yes/no button in my popup message box when user click "Submit"
button. It will check if the employee is a rehire, if yes, delete
record from tableA, if no, add record to table B. I understand it
might require to have a javascript for this popup box, but :cry: I
am not familiar with javascript, so I tried couple of alternatives
and it doesn't work. I tried confirm(), but it only has OK/Cancel
buttons. I tried RegisterClientScriptBlock, but it doesn't has a
Yes/NO button to trap the condition.

Can someone show me how to put the javascript in vb.net code? Please
help!

now I am trying RegisterStartupScript, and here is the code not
working:
conGPDb.Open()
Dim strStmt As String = "SELECT COUNT(distinct EmployID) FROM
DD00200 where employID=" + txtEmpID.Text + " and
DDTRANUM='555555555'"
Dim cmd2 As SqlCommand = New SqlCommand(strStmt, conGPDb)
Dim RehireInd As Boolean = True
If cmd2.ExecuteScalar() > 0 Then
Dim popupScript As String = "<script
language='javascript'>" & _
"window.open('PopUp.aspx', 'CustomPopUp', " & _
"'width=200, height=200, menubar=yes, resizable=no')"
& _
"</script>"
ValidRecord = False
Page.RegisterStartupScript("Script",
"<script>VerifyForm()</script>")

End If
conGPDb.Close()
-------------------------------------------------------

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Ad

Advertisements

K

Kevin Spencer

You have 2 choices: alert() or confirm() in JavaScript. Now, if you want
something fancier than that, you will have to write an ActiveX control or
Java applet to do it. My guess is you'll settle for confirm().

BTW, for ASP.Net, not knowing JavaScript is bad, m'kay?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
 
J

JenHu

I was using confirm(), but can you show me an example of how to change
Ok/Cancel button to Yes/No button so that I can trap conditions to the
code?
For example, if user click yes, then I have to delete a record from
TableA.
-------------------------------------------------------------------
btnSubmit.Attributes.Add("onclick", "javascrip:if(confirm ('Is the
employee a rehire?') == false) return false")
-----------------------------------------------------------------

Thx!

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
 
Ad

Advertisements


Top