在用户控件asp.net中使用页面方法的替代方法

meh*_*595 4 asp.net ajax user-controls pagemethods

有没有办法在用户控件中实现页面方法的功能.

任何帮助表示赞赏,谢谢:)

And*_*ett 5

最简单的方法可能是将您想要的功能放在Web服务中,然后使用scriptservice属性使其可用.

与页面方法的工作方式非常相似.

这里有一个广泛的例子.

        <asp:ScriptManager>
            <Services>
                <asp:ServiceReference Path="~/MyWs.asmx" />
            </Services>
        </asp:ScriptManager>
Run Code Online (Sandbox Code Playgroud)

然后你可以在JS中调用你的webmethods:MyNamespace.MyWs.MyMethod();