Hi Oliver,
I am returning false. Here is what I am doing...
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="_index.aspx.vb"
Inherits="Demo.__index"%>
<html><head><title>Validate</tile>
<script language="JavaScript" type="text/JavaScript">
<!-- // Hide older browser
function validate()
{
alert("Client-Side validation!");
return false;
}
}
//-->
</script>
<body>
<table>
<tr valign="top">
<td align="center" bgcolor="#ffffff" colspan="2"><br>
<asp:button id="cmdRunReport" runat="server" text="Run
Report"></asp:button><br>
<br>
</td>
</tr>
</table>
</body>
</html>
Behind-Code
'/// <summary>
'/// The main entry point for the application.
'/// First validate on client-side
'/// </summary>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'--// If the page has already loaded do not execute it again
If Not Page.IsPostBack Then
cmdRunReport.Attributes("onclick") = "validate();"
End If
End Sub
'/// <summary>
'/// Upon click "Run Report" The user is redirected to a "Loading..." page.
'/// </summary>
Private Sub cmdRunReport_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles cmdRunReport.Click
Response.Redirect("Loading.aspx?URL=Invoice.aspx?" )
End Sub
The problem is that when I click on the button is will execute the validate
client-side function but it will also execute the server-side
cmdRunReport_Click event. How can I prevent this from happening?
Yama
"Oliver" <DE*******************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Yama,
If you don't want the post to go ahead, use
return false;
from the JavaScript function.
"Yama" <yk*****@grandpacificresorts.com> wrote in message
news:eI**************@TK2MSFTNGP11.phx.gbl...
Hi,
I have a button which is a server-side control. If a client-side error on
a form is produced and a javascript (client-side) is fired how do I avoid
the server-side button_client event to occur? (that is because the page gets
refreshed for no reason even if I say do nothing)
Thank you,
Yama