| re: want to link form.submit to button_clik method
The System.Web.UI.WebControls.Button object can render HTML that already
uses the onMouseDown event. Why not just use an input type=button object
which references that script directly?
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows XP
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Billy" <billy_lenrage@hotmail.com> wrote in message
news:010401c394cc$6d2c87e0$a301280a@phx.gbl...[color=blue]
> 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[/color] |