B
Billy
Hi.
I'm new to asp.net and I'm trying to create a confirm
dialog box using the confirm() javascript function that
will pup once the submit button is pressed. My problem
is when I call document.forms[0].submit() in the script,
I would like to execute the code in the click event of
the submit button. How could I link this event to the
Form.submit function?
Here's the code :
<CODE>
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Confirm("Do you want to continue?")
End If
End Sub
Function Confirm(ByVal Msg As String)
Dim sb As New System.Text.StringBuilder
sb.Append(" <SCRIPT LANGUAGE = javascript>")
sb.Append("<!-- " & vbCrLf)
sb.Append(" function confirmSave(){" & vbCrLf)
sb.Append(" if (confirm(" & """" & Msg & """" & "))
{" & vbCrLf)
sb.Append(" document.forms[0].submit();" & vbCrLf)
sb.Append(" }" & vbCrLf)
sb.Append("}" & vbCrLf)
sb.Append("--></script>" & vbCrLf)
RegisterClientScriptBlock("cs", sb.ToString)
BSubmit.Attributes.Add("onMousedown", "confirmSave()")
End Function
Private Sub BSubmit_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BSubmit.Click
' Some action is in the submit button Click event
[...]
End Sub
</CODE>
Thanks a lot!
Billy
I'm new to asp.net and I'm trying to create a confirm
dialog box using the confirm() javascript function that
will pup once the submit button is pressed. My problem
is when I call document.forms[0].submit() in the script,
I would like to execute the code in the click event of
the submit button. How could I link this event to the
Form.submit function?
Here's the code :
<CODE>
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Confirm("Do you want to continue?")
End If
End Sub
Function Confirm(ByVal Msg As String)
Dim sb As New System.Text.StringBuilder
sb.Append(" <SCRIPT LANGUAGE = javascript>")
sb.Append("<!-- " & vbCrLf)
sb.Append(" function confirmSave(){" & vbCrLf)
sb.Append(" if (confirm(" & """" & Msg & """" & "))
{" & vbCrLf)
sb.Append(" document.forms[0].submit();" & vbCrLf)
sb.Append(" }" & vbCrLf)
sb.Append("}" & vbCrLf)
sb.Append("--></script>" & vbCrLf)
RegisterClientScriptBlock("cs", sb.ToString)
BSubmit.Attributes.Add("onMousedown", "confirmSave()")
End Function
Private Sub BSubmit_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles BSubmit.Click
' Some action is in the submit button Click event
[...]
End Sub
</CODE>
Thanks a lot!
Billy