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

RadCodeBlock in User Control

1 Answer 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fatima
Top achievements
Rank 1
Fatima asked on 22 Oct 2012, 05:54 AM
Hi
I have a user control that contains some Rad-controls (RadComboBox, RadMenu, AjaxPanel, ...) and some javaScript methods and it works correctly.

In my web site I need to use it in a panel that must be invisible at first page load, but unfortunately this property (visible = false) cause that user control's javascript isn't rendered and there are some errors about not finding javascript methods in the code page.

My user control's javascript code is in RadCodeBlock.

What is my solution?

How can I have a user control that can be invisible at first and after showing, its scripts has no errors?


1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 24 Oct 2012, 01:18 PM
Hi Fatima,

You could try the following approach:
<asp:Button ID="Button1" runat="server" Text="Toggle Visibility" OnClientClick="toggleVisibility();" />
<asp:HiddenField ID="HiddenField1" runat="server" Value="none" />
<asp:Panel ID="Panel1" runat="server">
JavaScript:
function pageLoad() {
    $get("<%= Panel1.ClientID %>").style.display = $get("<%= HiddenField1.ClientID %>").value;
}
function toggleVisibility() {
    var value = $get("<%= HiddenField1.ClientID %>").value;
    $get("<%= HiddenField1.ClientID %>").value = value == "none" ? "" : "none";
}

I hope this will prove helpful. Please give it a try and let me know about the result.

All the best,
Eyup
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
General Discussions
Asked by
Fatima
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or