SetFocusOnError

S

Shooter

Hi,

I'm having problems getting validation controls to set the focus back to the
textbox that caused the error (or any error). Using ASP.Net 2 and IE 6.

Does anyone have a solution to help me out on this one? Heres some code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebForm1" %>

<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" />

<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
SetFocusOnError="true"
ErrorMessage="TextBox1 is empty" ControlToValidate="TextBox1"
runat="server"/><br />
<asp:TextBox ID="TextBox2" runat="server" />

<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
SetFocusOnError="true"
ErrorMessage="TextBox2 is empty" ControlToValidate="TextBox2"
runat="server"/>
<br />
<asp:Button ID="Button1" runat="server" Text="Button"
CausesValidation="true"/>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
ShowMessageBox="True"
ShowSummary="False" />
</div>
</form>
</body>
</html>
 
S

Shooter

Hi timmy123,

I tried this on my laptop and home and found it also worked so I'm putting
it down to either differing versions of IE or maybe something that occurred
with the conversion of this project from 1.1 to 2.0 via the wizard.

It maybe the conversion as the page I copied the code from had a demo of it
and it was working ok in the same IE ver here at work.
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top