0

I have created a sandboxed solution for SharePoint 2013 which contains sandboxed visual webpart.

I need to call JavaScript function from back end. How can I accomplish this requirement? How can we load the .aspx page and where will I write the code behind so that I can get the variables passed using JavaScript function.

I have to perform some action on server side before calling JavaScript function, so I have to make call from back end. I am not able to do it using

Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "resultSetFunction();", true);.
1
  • There's a need (or reason) for call javascript function from back end instead make all the logic in javascript? Jun 4, 2015 at 19:55

1 Answer 1

0

use variable this

this.Page.ClientScript...

Make sure u have referred JS file in the visual webpart.

9
  • I have tried it with this.Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "resultSetFunction();", true); and added alert on document.ready. I am able to get alert but Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "resultSetFunction();", true); is not working... Can you plz give any other solution. Thanks for this one. May 14, 2015 at 10:56
  • Use Registerclientscript instead of RegisterStartupScript
    – Shiva
    May 14, 2015 at 11:03
  • it seems you are calling "resultSetFunction()" function in the script which i guess u have written in JS file, if it is the case this will not work. Because you are running the register script function on serverside and pointing to client side script.
    – Shiva
    May 14, 2015 at 11:06
  • ohh...Ok.I am registering my script on RenderControl() method then what should I write on back end to call any function of that script file ? May 14, 2015 at 11:47
  • You have register the JS function on Server side - we do this generally only for the samll function. You have t revise your business logic to implement. But the proposed comments solves your question.
    – Shiva
    May 14, 2015 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.