Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 5th, 2007, 11:56 AM
Authorized User
Join Date: Aug 2006
Posts: 39
Thanks: 1
Thanked 0 Times in 0 Posts
Default 'event.returnValue=false' equivalent for Firefox


I have to stop processing on page validation in javascript in Firefox.
here is my code. What is 'event.returnValue=false' equivelent for Firefox?

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            Button1.Attributes.Add("onclick", "javascript:checkForm();");

    protected void Button1_Click(object sender, EventArgs e)
        LabelError.Text = System.DateTime.Now.ToString();

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
        function checkForm()
            if(document.getElementById('txtUserName').value =="")
                if (window.event) //IE
                 window.event.returnValue = false;
                else //Firefox
                 window.event.preventDefault(); // <-- What should I write here instead
    <form id="form1" runat="server">
    <div align="center">
        <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><br/>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /><br />
        <asp:Label ID="LabelError" runat="server"></asp:Label>


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing RETURNVALUE from SP using FormView mtschindler ASP.NET 2.0 Basics 1 April 15th, 2008 04:40 AM
UsingJavaScript ReturnValue param99 ASP.NET 1.0 and 1.1 Professional 3 November 10th, 2006 05:49 AM
return (false) crmpicco Javascript 1 October 24th, 2005 11:39 AM
event handling with firefox jon8884 Javascript 1 June 16th, 2005 10:20 AM
Command Button False equivalent pinkandthebrain VB.NET 2002/2003 Basics 2 February 2nd, 2004 11:09 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.