开发者

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

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 Scri开发者_开发知识库ptManager 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,


Use a regular ScriptManager instead of the RadScriptManager:

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


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.')                    
                }
            });
        });


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

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜