Y
Yama
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 it will execute the
client-side validate function but it will also execute the server-side
cmdRunReport_Click event. How can I prevent a round-trip from happening? I
only want the validate function on client side to happen if it returns
false.
Yama
<%@ 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 it will execute the
client-side validate function but it will also execute the server-side
cmdRunReport_Click event. How can I prevent a round-trip from happening? I
only want the validate function on client side to happen if it returns
false.
Yama