Odeslat dotazOdeslat dotaz
 

OdpovědětJquery call to SharePoint Content Page method

  • 13. listopadu 2009 21:03Keval Shah Uživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaile
     
    Hi,

    I am using a SharePoint publishing page layout. There is a link on a page and when someone clicks on the link it should call a page method. I want to achieve this using JQuery so that the page does not get refreshed.
    I have tried the following things -
    1. Created an aspx page where i declared a Static WebMethod in .cs file & on click of the link i am calling this method using JQuery. This approach worked fine with ASP.Net. But when i tried the same with SP Content Page it did not work.
    2. Created a .ascx User Control which contained the method & called the method from JQuery, but it did not work.

    Please provide some guidance in this. Also let me know if there is a better approach to achieve this.

Odpovědi

  • 17. listopadu 2009 0:11Sundar Narasiman MVPMVPUživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaile
     Odpovědět

    I don't think you can call a method in a c# code from page layout, unless you have the code-behind for the page layout. It look like you want to call a method present in the application page, from jquery embeeded inside page layout. I don't think it is feasible. Just create a web service and expose the function as web method, so that you can call this readily


    Sundar Narasiman

Všechny reakce

  • 17. listopadu 2009 0:11Sundar Narasiman MVPMVPUživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaile
     Odpovědět

    I don't think you can call a method in a c# code from page layout, unless you have the code-behind for the page layout. It look like you want to call a method present in the application page, from jquery embeeded inside page layout. I don't think it is feasible. Just create a web service and expose the function as web method, so that you can call this readily


    Sundar Narasiman
  • 23. listopadu 2009 3:48Keval Shah Uživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaile
     

    I don't think you can call a method in a c# code from page layout, unless you have the code-behind for the page layout. It look like you want to call a method present in the application page, from jquery embeeded inside page layout. I don't think it is feasible. Just create a web service and expose the function as web method, so that you can call this readily


    Sundar Narasiman
    I have the code behind file for the page layout. I tried calling the function from jquery, written inside the class file, but it failed.
  • 9. prosince 2009 14:57Ryan Powers Uživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaileUživatelské medaile
     
    What did you end up doing to solve this problem?  I have just gone down essentially the same path you did.  Seems like the webservice approach should work, but I'm not sure how I would include that in my sharepoint web app or if I would have create a separate web service. 

    Any guidance?
    Clarity Consulting