CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Members   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 6/21/2007 2:41:37 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 13 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
dab1969
Asp.Net User
Tabindex problem6/21/2007 2:41:37 PM

0/0

I am able to tab through all my controls in the correct order, but near the bottom of my page I have 4 check boxes and they postback.  So, after you check one of them by using the spacebar, after returning from the postback the tabindex seems to start over instead of continuing on to the next control.  I need to have it continue where it left off.  Is there a way to do this?  Maybe in JS?  If so, especially if JS, could you provide an example?

I tried to setfocus to the next control during the postback of the checkbox, but it still went to the 1st control after the postback.

Thanks David

 

Benson Yu - MSF
Asp.Net User
Re: Tabindex problem6/25/2007 8:06:00 AM

0/0

Hi David,

From your description, I understand that you want to maintain the focus on the checkbox which result last post back by press spacebar. Based on this situation, I have provided the following code for your reference. Hope it is helpful to you.

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript">
        function SaveFocus(checkboxid)
        {
            if (event.keyCode ==32)
            {
                document.getElementById('Hidden1').value = checkboxid;
            }
        }

        function StartUpScript()
        {
            if (document.getElementById('Hidden1').value != '')
            {
                document.getElementById(document.getElementById('Hidden1').value).focus();
            }
        }
    </script>

</head>
<body onload="StartUpScript()">
    <form id="form1" runat="server">
        <div>
            <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox1')"
                Style="position: static" Text="aaa" />
            <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox2')"
                Style="position: static" Text="bbb" />
            <asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox3')"
                Style="position: static" Text="ccc" />
            <asp:CheckBox ID="CheckBox4" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox4')"
                Style="position: static" Text="ddd" />
        </div>
        <input id="Hidden1" runat="server" type="hidden" value="" />
    </form>
</body>
</html>


Sincerely,
Benson Yu
Microsoft Online Community Support

Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
dab1969
Asp.Net User
Re: Tabindex problem6/25/2007 2:01:45 PM

0/0

Thanks for the reply.  I'm getting this message now.

Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.

Source Error:

Line 6:              if (event.keyCode ==32)
Line 7:              {
Line 8:                  document.getElementById('Hidden1').value = checkboxid;
Line 9:              }
Line 10:         }

 

By the way, I'm using a master page.

Benson Yu - MSF
Asp.Net User
Re: Tabindex problem6/26/2007 8:06:00 AM

0/0

Hi David,

If you are using master page, please refer to the following code.

<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="UseMaster.aspx.cs" Inherits="Test.WebForm2" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox1')"
        Style="position: static" Text="aaa" />
    <asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox2')"
        Style="position: static" Text="bbb" />
    <asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox3')"
        Style="position: static" Text="ccc" />
    <asp:CheckBox ID="CheckBox4" runat="server" AutoPostBack="true" onkeypress="SaveFocus('CheckBox4')"
        Style="position: static" Text="ddd" />
    <input id="Hidden1" runat="server" type="hidden" value="" />

    <script type="text/javascript">
        function SaveFocus(checkboxid)
        {
            if (event.keyCode ==32)
            {
                var hidden = document.getElementById('<%= Hidden1.ClientID %>');
                hidden.value = hidden.id.replace('Hidden1',checkboxid);
            }
        }

        function StartUpScript()
        {
            if (document.getElementById('<%= Hidden1.ClientID %>').value != '')
            {
                document.getElementById(document.getElementById('<%= Hidden1.ClientID %>').value).focus();
            }
        }
    </script>
</asp:Content>

********** Site1.Master
??.
<body onload="StartUpScript()">
    ??..
</body>
??.

By the way, both demo codes I provided in this thread work well on my machines. If there are something error on your side, please create a new page or new project and copy all the code without modification to test.


Sincerely,
Benson Yu
Microsoft Online Community Support

Please remember to click ?Mark as Answer? on the post that helps you, and to click ?Unmark as Answer? if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
dab1969
Asp.Net User
Re: Tabindex problem6/26/2007 8:51:19 PM

0/0

Well, I got strange results.  I copied your sample page into a new page within my project.  It worked great.  I then placed it into my problem page.  No go.  It would not retain the "last" index in order to start back on that control.  I placed an alert("inside of Startup script") and alert("inside of SaveFocus script") into each of the functions to make sure that they were getting executed from my problem page.  The alerts would pop-up just fine, but then the checkbox would not retain the value (checked or unchecked) - The checkbox checked event would not fire. 

I placed the same alert popups into the test page, and they would not popup nor would my checked event fire. 

I have an ajax update panel on my page, so I took it out thinking that was the problem, but that did not help.  I tried to duplicate my code as much as possible other than all of my tables and multiple controls.  I just don't see what is happening.  It has to be something within my page, but don't know what. 

Thanks for the help

David

 

5 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

ValidateRequest Problem, need help! - ng.asp-net-forum ... http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=285251. Jared Livingston ... The problem is ... site, script injection attacks are a problem ...
Juicy Studio: Keyboard Navigation and Internet Explorer Providing a tabindex value of "0" solves the problem of in-page links where the ... The problem with this technique is that a valid tabindex value automatically ...
WebAIM: Keyboard Accessibility - Altering the Default Tab Order Using ... The main problem with tabindex is that it can create an illogical tab order, ... in the markup itself, rather than try to hide the problem by using tabindex. ...
Treeview Tabindex Problem - Configure It! ( How do I...? ) - DotNetNuke DotNetNuke® Forums ... 5/23/2007 4:27 AM. Kavita. 7 posts. Treeview Tabindex Problem. How can I set tabindex for Microsoft Treeview control in my application ...
Adobe - ActionScript 1 and 2 tabIndex problem - LucaLT - 02/25/2007 01:22:45 PM ... Re: tabIndex problem - kglad - 02/26/2007 07:33:31 AM ... I'm experiencing some problems using tabIndex. ...
Textpattern: Hacking the Comment Form's Tabindex " Jaredigital Articles Jaredigital is the personal portfolio and weblogue of Jared Christensen, web ... Another problem is this: what if you are already using tabindex values in your ...
ModalPopupExtender resets TabIndex to -1 - ASP.NET Forums If anybody else knows a better way to solve this problem please let me know. ... problem is that after it fires a second time, none of the tabindex properties ...
Staying positive about tabindex ¶ Personal Weblog of Joe Clark, Toronto HTML requires tabindex to be a number between 0 and 32767. ... How are you going to resolve the problem of applying tabindex to everything under the sun? ...
might be a bug... dont know... (tabindex couse problems...) ( tabindex couse problems...) Poster: dekel. Dated: Tuesday ... the problem is that i dont go to the next input as in the 'tabindex', i go to the menu...
FCKeditor - TabIndex? is it possible to set a tabindex for the editor field? thanks all! ... The problem I had was using tabindex with multiple editors in one page, I ...


 
All Times Are GMT