Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 30th, 2008, 05:21 AM
Registered User
 
Join Date: Jul 2008
Location: Varanasi, UP, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to om_anshuman
Default using JavaScript var in C# ASP.net

Hi,

can any one tell me that how can I use javascript var in ASP.net C# .


Anshuman
 
Old July 30th, 2008, 01:49 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

You can't. Period.

That's not how client/server programming works.

The variable in JavaScript is in the browser, which is in some computer in an airplane flying over the Pacific Ocean, say.

The C# code is on the server, sitting on the ground in London, say.

There is no way for the C# code to "reach out" and grab the value of that JS variable and use it.

The only way to get the value from the browser to the server is to *SEND* it there. With ASP.NET programming, that probably means copying the variable's value into a HIDDEN FORM FIELD and then submitting the form. Then the C# code can get the value from the submitted form.

You need to read up on the fundamentals of HTTP and client/server programming. Wish I could point you to a good book, but I can't think of the right one, off hand.
 
Old July 30th, 2008, 01:53 PM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You may want to take a look here:

http://p2p.wrox.com/topic.asp?TOPIC_ID=11765

Although my post discusses classic ASP, the general principle holds for ASP.NET as well.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.




Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript in asp.net Komila Generics 0 August 3rd, 2006 01:24 AM
javascript with asp.net rajatake ASP.NET 1.0 and 1.1 Professional 0 June 22nd, 2006 04:35 AM
passing js var to asp sql okl Javascript 1 March 11th, 2005 05:40 AM
passing js var to asp sql okl Classic ASP Databases 1 March 11th, 2005 05:01 AM
Asp Results in var prgaspar Classic ASP Basics 4 August 19th, 2003 07:24 AM





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