B
bauer.todd
The following page works fine on FireFox (the custom validator checks
to make sure that there's a value in the file upload text box).
However, on IE 7, when there's a value in the text box, the page
doesn't post-back when clicking submit. Can anyone reproduce or offer
some advice?
ASPX file
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function ValidateFileUpload(sender, args)
{
if (args.Value.length > 0)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="fu" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="ValidateFileUpload"
ControlToValidate="fu" ErrorMessage="CustomValidator"
ValidateEmptyText="True"
OnServerValidate="CustomValidator1_ServerValidate">*</
asp:CustomValidator><br />
<asp:Button ID="btnOK" runat="server" Text="Submit"
OnClick="btnOK_Click" />
</div>
</form>
</body>
</html>
CODE BEHIND file
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOK_Click(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (args.Value.Length > 0)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
}
to make sure that there's a value in the file upload text box).
However, on IE 7, when there's a value in the text box, the page
doesn't post-back when clicking submit. Can anyone reproduce or offer
some advice?
ASPX file
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function ValidateFileUpload(sender, args)
{
if (args.Value.length > 0)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="fu" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server"
ClientValidationFunction="ValidateFileUpload"
ControlToValidate="fu" ErrorMessage="CustomValidator"
ValidateEmptyText="True"
OnServerValidate="CustomValidator1_ServerValidate">*</
asp:CustomValidator><br />
<asp:Button ID="btnOK" runat="server" Text="Submit"
OnClick="btnOK_Click" />
</div>
</form>
</body>
</html>
CODE BEHIND file
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnOK_Click(object sender, EventArgs e)
{
}
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
if (args.Value.Length > 0)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
}