This is a migrated thread and some comments may be shown as answers.

JS Error on Hide,Show Control

1 Answer 94 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Andrey
Top achievements
Rank 1
Andrey asked on 15 Aug 2012, 08:23 PM
I am having some trouble with radscriptblock when the parent control is hidden and shown again through an ajax postback.

JSTest.aspx.cs: http://pastebin.com/G4ZFB32z
JSTest.aspx: http://pastebin.com/YpQWidRC
MyControl.aspx.cs: http://pastebin.com/NfXrQGiL
MyControl.aspx: http://pastebin.com/DZkJeJzd

When I click "Hide", the panel and control inside it become hidden. When I click show, the control is shown, but I get the following javascript error: 
Uncaught TypeError: Cannot read property 'currentStyle' of undefined Telerik.Web.UI.WebResource.axd:6
Sys.UI.DomElement.getVisible Telerik.Web.UI.WebResource.axd:6
Sys.UI.DomElement.setVisible Telerik.Web.UI.WebResource.axd:6
Sys.UI.Control.set_visible Telerik.Web.UI.WebResource.axd:6
InstalledByCheckChanged JSTest.aspx:8
(anonymous function) JSTest.aspx:2

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 20 Aug 2012, 03:15 PM
Hello Andrey,

Please try moving the checkUILoaded function declaration in the InstalledByCheckChanged function:

function InstalledByCheckChanged()
{
    var fromBox, toBox;
    var byUserRadioBtn, byConhtractorsComboBox;
 
    function checkUILoaded()
    {
        if (typeof (fromBox) == 'undefined' || fromBox == null)
        {
            fromBox = $find('<%= m_oByUsersSrcListBox.ClientID %>');
            toBox = $find('<%= m_oByUsersDestListBox.ClientID %>');
            byUserRadioBtn = $find("<%= m_oByUserRadioButton.ClientID %>");
            byConhtractorsComboBox = $find("<%= m_oByContractorComboBox.ClientID %>");
 
        }
        return typeof (fromBox) != 'undefined' && fromBox != null;
    }
    if (checkUILoaded())
    {
        if (byUserRadioBtn.get_checked())
        {
            fromBox.set_visible(true);
            toBox.set_visible(true);
            byConhtractorsComboBox.set_visible(false);
        } else
        {
            fromBox.set_visible(false);
            toBox.set_visible(false);
            byConhtractorsComboBox.set_visible(true);
        }
    }
}

I hope this helps.

All the best,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Ajax
Asked by
Andrey
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or