PageMethods is not defined

后端 未结 3 414
不知归路
不知归路 2021-01-14 00:11

I am setting up PageMethods to access server side code using javascript. I am receiving the error \"PageMethods is not defined\" when i debug using firebug. the server side

相关标签:
3条回答
  • 2021-01-14 00:46

    Page Methods don't work in either Master Pages or User Controls.

    If you move the method up one level to you page it should work.

    Never really been able to get a definitive answer on this one.

    I suspect it has do with the fact that aspx pages inherit from the Page class and the ascx controls inherit from the UserControl class. As to why of that I am not too sure.

    Personally I would use a generic handler (.ashx) page and call that through javascript.

    0 讨论(0)
  • 2021-01-14 00:51

    set EnablePageMethods="true"

     <ajaxToolkit:ToolkitScriptManager ID="scriptManager" 
                                   runat="server" 
                                   AsyncPostBackTimeout="99999999"
                                   EnablePageMethods="true" />
    

    i hope this will work for you

    0 讨论(0)
  • 2021-01-14 01:01

    As far as I understand, PageMethods on usercontrol is not supported and threads below seem to confirm that

    http://forums.asp.net/p/977525/1242935.aspx

    ASP.NET AJAX Page Methods from UserControl

    But I think there could be a workaround (not sure if that's efficient in your scenario). You can write a OneLine PageMethod in page's code behind which would intern call the Controls Page method. Now you can invoke your page's method from aspx and all set to go.

    Or you may use ths alternative Alternate way to use page method inside user control asp.net

    0 讨论(0)
提交回复
热议问题