2
votes

I have a ScriptManager which is added to my MasterPage;

 <telerik:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true" />

I have a Web User Control which is placed on the master page.

Inside the web user control, I'd like to use PageMethods but it complains that PageMethods is not defined.

 function ddlSqlConnections_SelectedIndexChange(selectedValue) {

        PageMethods.OnSelectedIndexChanged(selectedValue);
        location.reload(true);
    }

I added a new ScriptManager to the user control and it complained that only one scriptmanager can exist on one page so

basically how to add a reference to the master page script manager, from the user control?

It doesn't seem to be possible?

Thanks,

3
If you have scripetmanager in the master page, you dont need to anything in the user control. Just make sure ScriptManager loads before Usercontrol.Asdfg

3 Answers

0
votes

Use a regular ScriptManager instead of the RadScriptManager:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
0
votes

My conclusion was it's not possible with a Web User Control Page Method and I used AJAX with web service instead:

$('.ddlSqlConnections').change(function (control) {

            var selectedValue = control.currentTarget.value;            
            if (selectedValue == 0) {
                return;
            }

            $.ajax({
                type: "POST",
                url: "AdminService.asmx/AdminConnectionsOnSelectedIndexChanged",
                data: "{uniqueName: " + selectedValue + "}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {                                        
                    location.reload(true);
                },
                error: function (msg) {
                    alert('failed to send a web service request; please contact the administrator.')                    
                }
            });
        });
0
votes

You could try to Invoke a method in your masterpage from your userconrol.

 Page.GetType().InvokeMember("MethodName", BindingFlags.InvokeMethod, null, this.Page, new object[] { });