10

Closed

Error in Tabs Ajax Control Toolkit.

description

Hi,

I found an error in Tabs of ajax control toolkit, I have downloaded the last version of June 2012 Release, the erros occors in the other versions too.

The error consist in have a TabContainer inside a Tab of other TabContainer, inside an update panel.
When run the application an error of "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."

The error occors only in the IE 8, I dont have IE 7 for test. The error dont occors in IE 9 compatibility mode.

I have resolved this error, add a try/catch block in js script "Tabs.pre.js" where the focus of tab is set.

Attachment the application that occors the bug.

Ivan Patrick.

file attachments

Closed Dec 14, 2013 at 1:39 AM by Superexpert

comments

ivanpfontanive wrote Aug 6, 2012 at 6:04 PM

Hi,

I made tests without update panel and the bug occors too.

Dear,

Ivan Patrick.

csmrkid wrote Sep 9, 2012 at 7:17 AM

I got this error occurs in IE 8 too;

adageamar wrote Sep 29, 2012 at 6:59 AM

I have the same issue but the thing i cant view tabcontainer while debuging but on my another computer it work fine.

mbardon wrote Dec 6, 2012 at 10:44 AM

I am getting this error still too. Using IE8 and have tried a simply nested tab and the error is there.

Using the September 2012 release and while I have seen that this has been fixed elsewhere I am not seeing this as a resolved issue yet. Here is simple code for you to test this against.

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"> <title></title> </head> <body>
<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <ajaxToolkit:TabContainer ID="FirstContainer" runat="server">
        <ajaxToolkit:TabPanel ID="FirstContainerPanel1" runat="server">
            <HeaderTemplate>1stContainerPanel1</HeaderTemplate>
            <ContentTemplate>1stContainerPanel1 Content</ContentTemplate>
        </ajaxToolkit:TabPanel>
        <ajaxToolkit:TabPanel ID="FirstContainerPanel2" runat="server">
            <HeaderTemplate>1stContainerPanel2</HeaderTemplate>
            <ContentTemplate>
                <ajaxToolkit:TabContainer ID="SecondContainer" runat="server">
                    <ajaxToolkit:TabPanel ID="SecondContainerPanel1" runat="server">
                        <HeaderTemplate>2ndContainerPanel1</HeaderTemplate>
                        <ContentTemplate>2ndContainerPanel1 Content</ContentTemplate>
                    </ajaxToolkit:TabPanel>
                </ajaxToolkit:TabContainer>
            </ContentTemplate>
        </ajaxToolkit:TabPanel>
        <ajaxToolkit:TabPanel ID="FirstContainerPanel3" runat="server">
            <HeaderTemplate>1stContainerPanel3</HeaderTemplate>
            <ContentTemplate>1stContainerPanel3 Content</ContentTemplate>
        </ajaxToolkit:TabPanel>
    </ajaxToolkit:TabContainer>
<div>

</div>
</form>
</body>
</html>

mbardon wrote Dec 6, 2012 at 11:15 AM

I uninstalled Version 4.1.60919 (Sept 2012) and installed Version 4.1.60623 (June 2012) which stated that this issue was fixed in that release, but the same problem is there.

Fix is listed on http://ajaxcontroltoolkit.codeplex.com/workitem/27053 but this was not added to the source code.

I checked the source and the fix is definately not in there. Just need a try catch block added to Client\MicrosoftAjax.Extended\Tabs\Tabs.pre.js

//Added try catch block
_setFocus: function (obj) {
            try {
                $get("__tab_" + obj.get_element().id).focus();
            }
            catch (e) { }
        },

carlshe wrote Jan 23, 2013 at 2:08 PM

This issue occured in my project too. It works fine for IE9. But for IE8, the error always take place.
I hope it could be resolved as soon.

mbardon wrote Feb 7, 2013 at 10:28 AM

Hi there,

I checked this on the latest release (January 2013) and the issue is still there. This is 3 releases now that this has been though. Any ideas as to when this will get into the fix list?

Eaverae wrote Feb 13, 2013 at 9:56 AM

Guys I encountered the same issue, so I took the liberty to fix and recompile the toolkit for use with .Net Framework 4.0; See the attached file. I already tested it in my own solution, and it works like a charm. Please note that I was too lazy to change the version information, so you need to update the version information in your .config files.

Regards,

Guido Schippers

Kartris wrote Apr 28, 2013 at 7:48 PM

The attached 4.0 version doesn't fix it for me. In fact, it breaks tabs in Firefox and everything else too.

Kwantize wrote May 9, 2013 at 4:05 PM

I'm having the same issue. In our case we have a main page with a tab control and 3 - 6 tabs (I'm sorry that I can provide the code here, but I'll try to describe the structure in case it helps someone). Within each main tab, we have another tabcontrol with sometimes only 1, sometimes up to 7 (sub)tabs. In all browsers we've tested everything works fine, but an exception occurs in IE8 ("Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus"), resulting in incorrect rendering of the page (main tabcontrol is not rendered/visible).

We've tried all sorts to fix it - about 6 different versions of the Ajax toolkit (ASP 3.5; VS 2008 SP1), different jQuery versions (just in case), HTML validation (which pointed me to an additional problem with duplicated id's in tabcontrol divs created by the toolkit, which I have also not been able to overcome). In the end I simplified the code and found the offending piece of code, but have not been able to find a solution yet.

The exception occurs when we add a tabcontrol to the second tab of the main tab control (where the first tab in the main tab control will have initial focus as per default). I suspect the javascript generated by the toolkit tries to focus on the first tab of the tab control in the second main tab, and not finding it (because only the first main tab is visible when the page is loaded). But it's pure guesswork.

It sounds like the same problem noted here, but this one is set to closed even though lots of folk experience the same thing way after it was closed:
https://ajaxcontroltoolkit.codeplex.com/workitem/27053

I don't know whether the Javascript solution (try/catch block) would work here, but my next step is probably to try and compile my own toolkit dll to see if that resolves it.

Kwantize wrote May 9, 2013 at 5:26 PM

So I've now gone through the slightly painful experience of implementing desterly's solution as noted in link above (and also by mbardon above) and rebuilt the AjaxControlToolkit from source. It works! Thank you desterly!

If you've made you're way to this page, and have the same issue, I can safely say stop browsing for a short cut, download the source code and build the ACT yourself. I've spent most of yesterday evening and today looking for another solution, but not found anything.

A few hints for building ACT if you've never done it before (like me):
Go to "Source Code" and then "History". Select a change set/commit that has been downloaded lots of times before (I chose 31 Jan 2013 reference a2a6dc6854e0) and click on "Files". Have a quick read through the readme file and make sure the context is the correct commit/change set. Download the zip through the download option (top right). Unzip and open the solution in Visual Studio. Accept all the warnings and open project as normal. Set the build options to release and build the entire thing. In my case I had one error due to the website examples requiring ASP 4.5, so I excluded that project from the build and everything compiled fine. Look for the AjaxControlToolkit.dll after your build and use it in your project. Good luck - it's actually easier than I thought it would be.

I guess the smart folk at AjaxControlToolkit don't want to use a try without a proper catch, but it would be good to get the issue fixed once and for all. Ignoring a bug is in my opinion a lot worse than an ugly workaround.

Eaverae wrote May 13, 2013 at 12:30 PM

I guess the smart folk at AjaxControlToolkit don't want to use a try without a proper catch, but it would be good to get the issue fixed once and for all. Ignoring a bug is in my opinion a lot worse than an ugly workaround.
I couldn't agree more. I've encountered another bug that goes hand-in-hand with this one on the meantime. I also had trouble building the solution when I added the toolkit to our local Source Control.

Liri wrote Jul 31, 2013 at 9:58 AM

mbardon GOD bless you!!

chrislynn5 wrote Tue at 4:46 PM

why was this closed?