calling an ascx page method using jquery

后端 未结 8 1407
天涯浪人
天涯浪人 2020-12-01 14:16

I know that I can call a page method with jquery using the following syntax

$.ajax({
  type: \"POST\",
  url: \"Default.aspx/GetDate\",
  data: \"{}\",
  con         


        
8条回答
  •  孤街浪徒
    2020-12-01 14:44

    I don't think it's possible by requesting the ascx file directly--i.e. supplying "MyControl.ascx" as the url parameter to $.ajax(..). The ascx file isn't exposed directly by the web server.

    You can, I believe, supply the url of the aspx page containing the user control--i.e. if an instance of MyControl.ascx lives on MyPage.aspx you would have to supply "MyPage.aspx" as the url parameter. It sounds like that might defeat the purpose for what you're trying to accomplish though.

    EDIT: What Clyde said below seems like a good idea. I'm doing something similar myself by including the ascx control on a page whose job is more or less just to host it for access from client-side script.

提交回复
热议问题