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

problems with .visible

1 Answer 73 Views
XmlHttpPanel
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 15 Jun 2012, 11:43 AM
Hi. I'm using the XmtHttpPanel for the first time. At the moment I have the XmlHttpPanel within a <div id="panelDiv" runat="server">

At the moment I am using callback similar to the first look demo on the Telerik website (ie javascript to set the XmlHttpPanel.value and that then calling code behind).

If I set the panelDiv.visible = false; nothing seems to happen. If I set panel.visible = false; the panel disappears. However, if I then make another click that results in panel.visible=true; I get an error:

    Server Error in '/prototype' Application. 
    -------------------------------------------------------------------------------- 
     Script control 'Async_highlights' is not a registered script control. Script controls must be registered using RegisterScriptControl()
     before calling RegisterScriptDescriptors(). 
    Parameter name: scriptControl


I also have a button separate to the XmlHttlpPanel that I want to also use to switch the panel's visibility. I found problem using .visible but it seems to work using the display attribute.

Can you give any advice about the best way to hide/show an XmlHttpPanel dynamically (I don't care about the content because if the panel is subsequently revealed again the content will be updated).


1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 19 Jun 2012, 10:12 AM
Hello Paul,

You can use JavaScript to switch the CSS display property of the div element in order to toggle its visibility. The following code sample shows a possible approach to do this (SetVisibility is a handler of an input's onclick event):
function SetVisibility() {
    var panelDiv = $get("panelDiv");
    if (panelDiv.style.display == "none") {
        panelDiv.style.display = "block";
    } else {
        panelDiv.style.display = "none";
    }
}

As for the error that you encountered, the RadXmlHttpPanel loads it data by using ASP.NET's Callback mechanisms and Web Services. These methods do not offer Viewstate and there is no page lifecycle. This prevents the server-side event handlers from execution and therefore the server-side interaction among the controls inside the panel is limited. In your case most probably there is a ASP control in the RadXmlHttpPanel that strongly relies on ViewState, which results in the encountered problem. You should consider using the RadXmlHttpPanel for loading presentation data, which is its primary purpose.

Greetings,
Slav
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
XmlHttpPanel
Asked by
Paul
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or