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

Javascript functions not found in user control

5 Answers 110 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Brian
Top achievements
Rank 1
Brian asked on 16 Feb 2011, 07:18 PM
Hello

I'm trying to do something similar to what is shown in Controls --> RadAjax --> General FAQ and How-to -->Load user controls in the documentation.

I have a RadSplitter with 3 panes on a MasterPage.  The left pane contains a couple buttons that expand the middle pane when clicked - the middle pane contains a PlaceHolder control and I load in the user control as follows:

        Me.oCtrlDemo = LoadControl("~\user_controls\events_pane.ascx")
        Me.PlaceHolder1.Controls.Add(Me.oCtrlDemo)

So far so good.  This UserControl contains a list of 5 buttons, and each button calls a JavaScript function as follows (the JavaScript functions are declared at the top of the UserControl within a RadCodeBlock):

<asp:ImageButton ID="btnGridReport" runat="server" ImageUrl="~/images/events/document.png"
     onclientclick="show_EventInfoGrid(); return false;" ToolTip="Event Info Grid" />

When AJAX is disabled, I can click on a button in the UserControl and the JavaScript function is called - however, when AJAX is enabled, I get an error that the JavaScript function (show_EventInfoGrid()) cannot be found.  

Here is the AjaxManager code from the MasterPage:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                    <AjaxSettings>
                        <telerik:AjaxSetting AjaxControlID="btnEventsUsers">
                            <UpdatedControls>
                                <telerik:AjaxUpdatedControl ControlID="PlaceHolder1" />
                            </UpdatedControls>
                        </telerik:AjaxSetting>
                        <telerik:AjaxSetting AjaxControlID="btnSecurityPane">
                            <UpdatedControls>
                                <telerik:AjaxUpdatedControl ControlID="PlaceHolder1" />
                            </UpdatedControls>
                        </telerik:AjaxSetting>
                    </AjaxSettings>
                </telerik:RadAjaxManager>


Have been struggling with this - any suggestions greatly appreciated

Thanks

Brian

5 Answers, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 17 Feb 2011, 11:42 PM
Was just thinking about this and realized that if I put the scripts in the master page then then I should no longer get the error - will try this tomorrow...

Is there any reason why the javascript in the user control could not be accessed when the user control is loaded?
0
Brian
Top achievements
Rank 1
answered on 18 Feb 2011, 02:33 PM
In case anyone has a similar problem - I moved the scripts from the user control into an external javascript file that I reference from the master page and everything seems to be working properly

0
jose luis
Top achievements
Rank 1
answered on 25 Aug 2011, 11:15 PM
Hi have you found any solution to avoid moving the javascript outside the control file and not to register with the scriptmanager?

Thanks
0
jose luis
Top achievements
Rank 1
answered on 01 Sep 2011, 06:46 PM
hello

in this forum post i write the code with the changes to the sample code attached where can be seen that the alerta() javascript function is not executed and also not found if you try to call from firefox console.

Thank you for your support.

0
jose luis
Top achievements
Rank 1
answered on 12 Sep 2011, 08:43 AM
it's answered in the forum  described in the previus post.

thanks
Tags
Ajax
Asked by
Brian
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
jose luis
Top achievements
Rank 1
Share this question
or