ASP.NET 2.0 Default Button problem

M

MatsL

I have a simple test form with a panel and default button defined,
textbox, RequiredFieldValidator. If i open the form and press enter the
RequiredFieldValidator will prevent the form to be submittet but if i
press enter a second time the form will be submitted and
RequiredFieldValidator will be ignored. Is this by design? or how do i
prevent the form to be subbmitted a second time

// Mats

<%@ 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">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form defaultfocus="TextBox1" id="form1" runat="server">
<div>
<asp:panel ID="Panel1" runat="server" DefaultButton="Button1"
Height="218px" Width="428px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button"
ValidationGroup="1" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1"
ErrorMessage="RequiredFieldValidator"
ValidationGroup="1"></asp:RequiredFieldValidator></asp:panel>

</div>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top