I have a sandboxed solution in which I need to pass data from javascript to server side. Can anyone suggest me with help links or any ideas?

  • what kind of sandbox solution you are working on? are you deploying any visual webpart as sandbox ? Commented Oct 15, 2012 at 11:57
  • Yes. I em working with visual webpart in sandboxed solution
    – sharmila
    Commented Oct 15, 2012 at 11:58
  • Did you see this? sharepoint.stackexchange.com/a/45548/627
    – eirikb
    Commented Oct 15, 2012 at 12:21

2 Answers 2


If you really want then the best way is probably have a web part in the sandboxed code add a number or fields inside a div which is hidden using css and the let javascript fill out these fields and make a submit.

But why not use Client Side Object model and do everything in JavaScript?

  • Can you please help me with a hello world example? I am a beginner to sandboxed solutions.
    – sharmila
    Commented Oct 15, 2012 at 11:52


You can take a HiddenField in Visual WebPart and inside Javascript you can access it like:

<script type="text/javascript">
function setHiddenField()
    document.getElementById("<%=hiddenFieldID.ClientID %>").value = "your-value";

And you can access it on server side like: hiddenFieldID.Value

But remember, javascript should be in the Visual WebPart as well.. If you want to do this from page and not server side, then you can take HTML input control and access it through its id.. Let me know if you stuck somewhere!

I hope this helps...

  • I cannot use the javascript inside visual webpart since there are lot of fields and lot of controls whose values should be passed.l Is there any way of passing the data(headers) using ajax POST call to server side. I mean by giving the url of an aspx page?
    – sharmila
    Commented Oct 15, 2012 at 12:32
  • I see, can you please share what you are trying to do? And why are there so many fields? Maybe we can give you a solution which change your approach :) Commented Oct 15, 2012 at 12:42

Your Answer

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

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