Control.Focus() broken in Framework 2.0 RTM?

B

Benton

Hi there,

I was using VS 2005 Beta 2 and was able to set the focus to any control on a
web form by calling its Focus() method, for instance:

btnContinue.Focus();

Today I upgraded to VS 2005 RTM and now I get an exception at runtime when
the code execution reaches the above line. The exception I get is this:

System.InvalidOperationException was unhandled by user code
Message="A form tag with runat=server must exist on the Page to use
SetFocus() or the Focus property."
Source="System.Web"

I did nothing to my project, and of course the control has a "runat=server"
attribute.

Any ideas?

Regards,

-Benton
 
B

Benton

Hi there,
I was using VS 2005 Beta 2 and was able to set the focus to any control on
a web form by calling its Focus() method, for instance:

btnContinue.Focus();

Today I upgraded to VS 2005 RTM and now I get an exception at runtime when
the code execution reaches the above line. The exception I get is this:

System.InvalidOperationException was unhandled by user code
Message="A form tag with runat=server must exist on the Page to use
SetFocus() or the Focus property."
Source="System.Web"

[Edit]
This only happens if I set the focus inside the Activate method of a View (I
use the Multiview control). Perhaps this change of behavior is by design?

Regards,

-Benton
 

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,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top