473,785 Members | 3,417 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how do you set focus to next control on controls with autopostback so you don't have to hit tab twice?

I have autopostback turned on for Textbox1. When the user tabs out of
it, the codebehind recalculates some other fields based on its value,
and the user should be able to start typing a value in the next
control Textbox2. However, when the page is rendered, the focus goes
back to Textbox1. In order to go to the next control the user has to
hit tab twice - once to recalculate, and once to tab out of the
control. Is there some way to make it so that a single tab
recalculates AND brings the user to the next control?

I have tried putting in the following javascript to do it after
recalculation, but it doesn't seem to work:

(DO RECALCULATIONS HERE)
....

' SET FOCUS ON NEXT CONTROL
'Page.RegisterC lientScriptBloc k("SetFocus", "<script
language='javas cript'>document .form.Texboxt2. focus();</script>")
Nov 18 '05 #1
2 2342
the javascript (which will render after the form and before any controls) is
runnig before the control is rendered. execute on form load.

Page.RegisterCl ientScriptBlock ("SetFocus", @"<script> language='javas cript'>
document.body.o nload = function(){ document.form.T exboxt2.focus() ;}
</script>");
-- bruce (sqlwork.com)
"Mad Scientist Jr" <us************ *@yahoo.com> wrote in message
news:7a******** *************** ***@posting.goo gle.com...
I have autopostback turned on for Textbox1. When the user tabs out of
it, the codebehind recalculates some other fields based on its value,
and the user should be able to start typing a value in the next
control Textbox2. However, when the page is rendered, the focus goes
back to Textbox1. In order to go to the next control the user has to
hit tab twice - once to recalculate, and once to tab out of the
control. Is there some way to make it so that a single tab
recalculates AND brings the user to the next control?

I have tried putting in the following javascript to do it after
recalculation, but it doesn't seem to work:

(DO RECALCULATIONS HERE)
...

' SET FOCUS ON NEXT CONTROL
'Page.RegisterC lientScriptBloc k("SetFocus", "<script
language='javas cript'>document .form.Texboxt2. focus();</script>")

Nov 18 '05 #2
I tried it, but the focus still stayed on the control that had the
AutoPostback and I had to hit tab again to go to the next control.
Thanks anyway...
Nov 18 '05 #3

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

Similar topics

5
11381
by: tshad | last post by:
I have a date validation function that I want to stay at the object I am validating if there is a Validation error, but it always goes to the next object. The Javascript: function ValidateForm(me){ var dt=me if (isDate(dt.value)==false){ dt.focus()
4
3791
by: Christian Ista | last post by:
Hello, I have 2 questions : 1. On an ASP.NET page I have several controls (5 TextBox, 1 Dropdown and 1 button) Only the dropdown is AutoPostBack = true, the TextBox are SingleLine When I execute the page, I fill in the textbox, I change the dropdown selection, the page is reloaded no problem I see the textbox still fill in.
1
1968
by: robin9876 | last post by:
In Asp.Net v1.1 web form I have a number of controls which have the autopostback enabled. Is it possible after the autopostback has run that the control that caused the autopostback to get the focus?
4
4306
by: Jon Slaughter | last post by:
I've created some custom controls and forms that allow the feature to temporarily transfer focus to a control that has been entered by the mouse. Everything seems to work fine but the problem I have is that sometimes I seem to loose the original "holder" of focus and when the user hits tab while using "temporary" focus(while the mouse is over a control) it will change focus to the next control but not update it. So I have several issues....
1
2109
by: danyeungw | last post by:
I get the following from the link http://support.microsoft.com/kb/314206. I need to have both work - the page stays where it is and set focus to next control. Does anyone have solution? I have been working on this for days. I am using ASP.NET 2003. Thanks. DanYeung PRB: Controls Lose Focus When You Enable SmartNavigation and AutoPostBack View products that this article applies to. Article ID : 314206 Last Review : February 23,...
5
11657
by: Matt B | last post by:
I know this is a bit of nonstandard behavior, but I would like the Enter key to move focus through a group of radiobuttons without selecting them. The user would then have to use Space or actually click to select one of the radiobuttons to select. The default behavior of Focus() seems to also select the radiobutton, but I can't seem to find what is causing this to happen. I would like very much to seperate the Focus and the selection....
1
1478
by: Mufasa | last post by:
I have a couple of fields that are autopostback and I want to make tab work correctly between them. But whenever somebody changes the value and clicks somewhere else the page reloads as it should but there is no field with focus. So how can I tell what field the user clicked on before the page reloads, save that and set the focus to that field once they are done. TIA - J.
1
2158
by: RN1 | last post by:
Consider the following DataGrid: -------------------------------------------------------------------------------- <asp:DataGrid ID="dgMarks" AutoGenerateColumns="false" runat="server"> <Columns> <asp:TemplateColumn> <HeaderTemplate> <asp:CheckBox ID="chkHeader" OnCheckedChanged="CheckUncheckAllRows" AutoPostBack="true" runat="server"/> </HeaderTemplate>
8
6904
by: Mel | last post by:
I have several text boxes and drop-down lists in an AJAX Update Panel. All user inputs have the Postback property set to True. After I type something in the first input entry and press the "Tab" key how can I set the focus to the next box after the postback? Please help! Using Visual Studio 2005 Pro, Asp.net 2.0, vb.net, WinXP
0
9643
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
10147
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
10085
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,...
1
7494
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
6737
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();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4045
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
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.