[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to assisn a serverside variable using Javascript?

Posted on 2009-12-17
13
Medium Priority
?
416 Views
Last Modified: 2012-05-08
I need a technique to assign value to a server side variable using javascript.
( I don't wanna use the Hidden Field technique ).
0
Comment
Question by:princeatapi
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 40

Accepted Solution

by:
Gurvinder Pal Singh earned 626 total points
ID: 26071469
Could you explain on why do you want to do it?
0
 
LVL 11

Author Comment

by:princeatapi
ID: 26071490
i don't wanna use hidden field ( actually my page struggles to load , contains more than 60 hidden fields ) looking for a best alternate
0
 
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 626 total points
ID: 26071519
But why do you want to assign this value to a server side variable?
You can always append all the values to one field value separated by a delimiter and split the same on the server side.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Author Comment

by:princeatapi
ID: 26071599
well this is a very large scale application , already all the hidden field holds few kb's of data , which increases the page load time ...

most of the job is processed in client side ( using javascript ) hope u can understand the situation
0
 
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 626 total points
ID: 26071635
"most of the job is processed in client side"
"I need a technique to assign value to a server side variable using javascript"
Could you please give the complete context of what you are doing?

Thanks
0
 
LVL 8

Assisted Solution

by:deepu chandran
deepu chandran earned 250 total points
ID: 26071642
Hi,
You can use a web service called from Javascript using Ajax Script manager
<asp:ScriptManager ID="ScriptManager1" runat="server">
 <Services>
    <asp:ServiceReference Path="~/UrWebService.asmx" />
  </Services>
</asp:ScriptManager>

If you refer this into your Aspx page, you can access the web service class direclty.

Refer the below links,
http://www.semenoff.dk/en/Code-Corner/ASP.Net.AJAX/WebService-From-JavaScript.aspx

http://www.asp.net/Ajax/documentation/live/mref/T_System_Web_UI_ServiceReference.aspx

Hope you can use it in your application
Regards
Deepu
0
 
LVL 11

Author Comment

by:princeatapi
ID: 26071792
Hi gurvinder372: ,

k lemme give you a sample scenario , am having a Huge treeview out of which user can select any number of nodes say 20 , 30 ... any number , so far ive collected the id's repected to the slected node using javascript and update the hidden field , later i used to update the database by reading the values in the hidden field . is that clear for you ?
0
 
LVL 8

Assisted Solution

by:PeteEngineer
PeteEngineer earned 124 total points
ID: 26071851
0
 
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 626 total points
ID: 26071864
Yes, it is clearer.

I need to know how are you setting the values in hidden field.
You can simply append all the values in one field separated by a delimiter at the click event of submit button
like
var allValues = '';
var delimiter = '||';
for (loop through all nodes)
{
   if (node is selected)
   {
     allvalues = allValues + delimiter + nodeValue;
   }
}
document.form[0].hiddenfield1 = allValues;
document.form[0].submit;

I am not sure how you have implemented your treeview, so i could have suggested at bit more granular level. But i don't see any issue for you in implementing this solution

0
 
LVL 11

Author Comment

by:princeatapi
ID: 26071990
hi gurvinder372:!

 thats what am doing so far.. ive clearly mentioned not to use Hidden fields
0
 
LVL 40

Assisted Solution

by:Gurvinder Pal Singh
Gurvinder Pal Singh earned 626 total points
ID: 26072006
In that case you can simply append the values to server-side URL and make an Ajax call.

0
 
LVL 8

Assisted Solution

by:deepu chandran
deepu chandran earned 250 total points
ID: 26072026
What about Ajax Script manager? You cannot be ale to use it.
You can use Session Enabled Service calls to Send data to server side.
0
 
LVL 11

Author Closing Comment

by:princeatapi
ID: 31667282
Nothing Helped me as i Expected , still i wd like to encourage all you guys participated :) Thank you all
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month18 days, 12 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question