473,836 Members | 1,477 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control.Focus() broken in Framework 2.0 RTM?

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.Foc us();

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.InvalidO perationExcepti on 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=serv er"
attribute.

Any ideas?

Regards,

-Benton
Jan 5 '06 #1
1 1284
> 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.Foc us();

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.InvalidO perationExcepti on 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
Jan 5 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
5505
by: Matt Fielder | last post by:
I have developed a custom control to be used in my application. My application includes a form designer, so the control can be hosted while designmode for the control is either true or false, depending on whether they are using the form designer, or in "run mode". The custom control includes a slider control that is supposed to be active in our form designer (designmode=true) and inactive in our run mode (designmode=false). The problem...
6
5805
by: Alex Bink | last post by:
Hi, I have a validating event on a textbox in which I want to prevent the user to leave the textbox without entering the right data. Only if he clicks on another specific control he is allowed to leave the textbox without entering the right information. Is there a way to determine which other control was clicked in the validating event of the textbox? Thanks
7
1944
by: |{evin | last post by:
I'm currently working on what has turned in to something much larger that I wanted it to be. The upside is that I'm getting $$ to do it... but anywho. I currently have textboxes set up to capture phone numbers, I've also got regular expression validation in place to force the format of the number to be (xxx) xxx-xxxx. The problem is, the people that are paying me don't want this. What they'd like to see is a magic textbox that fills in...
1
1540
by: holysmokes99 | last post by:
I have a VB6 winforms application that has a .Net 2.0 user control (exposed via COM) that I made. No matter what I have tried, once the user control looses focus, it always requires a double-click to regain focus. My control is in a Microsoft VB6 Tab control. So whenever I go to another tab, and return to the tab with the user control, I must double-click the control to give it focus. I have tried giving it focus in code, passing a...
1
1344
by: holysmokes99 | last post by:
I have a VB6 Winform application that has a .Net 2.0 user control (exposed via COM Callable Wrapper) that I made. No matter what I have tried, once the user control looses focus, it always requires a double-click to regain focus. My control is located on a tab of a Microsoft VB6 Tab control. So whenever I go to another tab, and return to the tab with the user control, I must double-click the control to give it focus. I have tried giving...
9
18027
by: Zytan | last post by:
http://msdn2.microsoft.com/en-us/system.windows.forms.control.focus(VS.80).aspx this page says: "Focus is a low-level method intended primarily for custom control authors. Instead, application programmers should use the Select method or the ActiveControl property for child controls, or the Activate method for forms." I am trying to give a Numeric UpDown control focus. Only Focus() works. But this says to not use it.
8
1508
by: Chris | last post by:
Hi, i have in an content page a fieldset containing a label, an iframe and a textarea: <asp:Content ID="Content1" ContentPlaceHolderID="main" Runat="Server"> <fieldset style="width:650px;"> <asp:Label ID="Label1" runat="server"></asp:Label> <iframe ..... ></iframe> <textarea id="txta" rows="6"></textarea>
0
1024
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello Gurus, Using VS2005 with .NET Framework 2.0. I wrote a GUI control A derived from UserConstrol, this control contains another UserControl derived B which contains two Labels controls and two NumericUpDown controls. The trouble is: After one of the NumericUpDown get the focus by mouse click on it, I can not
2
2394
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello experts, I posted a disturbing question in here: http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.languages.csharp&mid=dedc665f-91c0-4fa4-a103-a98a6808759c But no one have answered it. Is not clear? or maybe it a Framework bug? Please help.
0
9814
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10543
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10585
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10249
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9368
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7786
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6976
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4447
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4009
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.