Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 9th, 2008, 06:01 AM
Authorized User
Join Date: Aug 2008
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default variables

How can I pass javascript variables in c#?
The problem is that I have a group of variables that in the first place I have to import them in javascript, do some work with them, end then call them back in c# to make a request to a server.
Thank You.

Reply With Quote
  #2 (permalink)  
Old September 9th, 2008, 07:06 PM
Friend of Wrox
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts

There are only two ways to pass data to *ANY* server side application: Via a query string or via POST data. And in both cases, you must do so by "hitting" a URL on the server.

In general, with ASP.NET, you would use POST data. And that means you must send the data by submitting a <FORM>.

So the first answer is simple: Use a form field (i.e., <INPUT NAME=whatever>).

And the expansion on that answer is also simple: Use hidden form field(s) and then use JavaScript coding to copy the value of the JS variable(s) into the form field value(s).

I assume this is related to your question about panning an image, so you could just do:
    document.forms[0].panX.value = panX;
    document.forms[0].panY.value = panY;
assuming you have hidden form fields named panX and panY and javascript variables of the same name. (No reason for them to be same; just makes sense for them to be, for housekeeping.)

Now when the user submits the <FORM> (presumably, by clicking on your ZOOM button), those values will be available to your C# code via simply
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
using variables webgrphx Classic ASP Basics 3 April 11th, 2007 06:46 PM
Global Variables in C# su C# 2 December 11th, 2006 06:18 PM
Passing Variables silve1999 Pro Java 1 June 15th, 2006 12:54 PM
undifined variables bogins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 April 19th, 2004 06:19 PM

All times are GMT -4. The time now is 07:02 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.