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);.
  • There's a need (or reason) for call javascript function from back end instead make all the logic in javascript? – Mauricio Arias Olave Jun 4 '15 at 19:55
0

use variable this

this.Page.ClientScript...

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

  • 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. – Trimantra Software Solution May 14 '15 at 10:56
  • Use Registerclientscript instead of RegisterStartupScript – Shiva May 14 '15 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 '15 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 ? – Trimantra Software Solution May 14 '15 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 '15 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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