SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
what kind of sandbox solution you are working on? are you deploying any visual webpart as sandbox ? – Arsalan Adam Khatri Oct 15 '12 at 11:57
Yes. I em working with visual webpart in sandboxed solution – sharmila Oct 15 '12 at 11:58
Did you see this? – eirikb Oct 15 '12 at 12:21

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?

share|improve this answer
Can you please help me with a hello world example? I am a beginner to sandboxed solutions. – sharmila Oct 15 '12 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...

share|improve this answer
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 Oct 15 '12 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 :) – Arsalan Adam Khatri Oct 15 '12 at 12:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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