Tip Details Add a Related Tip

Rate as: Positive Negative

Using ASP.Net variables in your Javascript code

One of the cool things about ASP.Net is that you can make use of your variables (from your ASP.Net code) in your Javascript code. If you have a variable called aVarName in ASP.Net, here's the Javascript code that makes use of the value of that variable:

var jVarName;
jVarName = '<%#aVarName%>';
Rating: 100% positive, 7 total Votes
Categories: programming ASP .Net javascript
Added: on May 05, 2007 at 7:00 am
Added By: an anonymous user
Searches: javascript code asp.net variable asp

Comments on this Tip

Add a Comment
This is a great tip. I've been looking for this information for about an hour when I finally found this link. Thanks big time!
– Added by an anonymous user on Jul 12, 2007 at 8:26 am
You can do that in php too.
var jVarName;
jVarName = '<?=$aVarName?>';

Probably in other languages too but I dont know them
– Added by an anonymous user on Sep 04, 2007 at 7:12 am
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

Setting the button triggered by the enter key

Categories: programming ASP .Net web
100% positive, 0 comments
– Tip added by an anonymous user on Jun 05, 2007 at 6:09 pm

Electronic payment processing in ASP.Net web applications

Categories: programming ASP .Net web
100% positive, 1 comment - last added on Apr 30, 2007 at 1:32 pm
– Tip added by an anonymous user on Apr 25, 2007 at 12:01 pm

Master pages in ASP.Net 2.0

Categories: programming ASP .Net
100% positive, 0 comments
– Tip added by an anonymous user on Apr 24, 2007 at 3:05 pm

Maintaining page scroll position with ASP.Net 2.0

Categories: ASP .Net programming
no ratings, 0 comments
– Tip added by an anonymous user on Jun 08, 2007 at 12:31 pm

Adding an email attachment in .Net

Categories: programming ASP .Net web
0% positive, 0 comments
– Tip added by an anonymous user on Apr 26, 2007 at 3:49 pm

Detecting if a variable exists in Javascript

100% positive, 2 comments - last added on Oct 21, 2009 at 2:29 pm
– Tip added by an anonymous user on Jul 22, 2008 at 8:31 am

jQuery ajax responseText empty

100% positive, 2 comments - last added on Aug 25, 2009 at 9:58 am
– Tip added by an anonymous user on Mar 27, 2009 at 8:26 am

Length of associative arrays in Javascript

100% positive, 0 comments
– Tip added by an anonymous user on Nov 04, 2008 at 10:13 am

Matching any character in a javascript regular expression

100% positive, 2 comments - last added on Oct 08, 2009 at 2:33 am
– Tip added by an anonymous user on Aug 18, 2008 at 9:06 am

reading select element values in javascript in IE7

100% positive, 0 comments
– Tip added by an anonymous user on Jul 17, 2009 at 1:28 pm

Unable to click in text input boxes on Internet Explorer

100% positive, 2 comments - last added on Aug 07, 2009 at 4:57 pm
– Tip added by Marcos84 on Dec 09, 2008 at 10:49 am

Optional parameters in javascript functions

100% positive, 0 comments
– Tip added by an anonymous user on Jul 30, 2008 at 10:44 am

Using optional parameter in javascript

Categories: javascript programming
100% positive, 0 comments
– Tip added by an anonymous user on Jul 17, 2008 at 7:49 am

Javascript Error: unterminated regular expression literal

50% positive, 0 comments
– Tip added by marty on Jun 26, 2008 at 1:20 pm

Don't include a "length" attribute in a JSON Object

100% positive, 0 comments
– Tip added by an anonymous user on Apr 10, 2009 at 4:51 pm

Checking for undefined variables in Javascript

100% positive, 1 comment - last added on Jul 14, 2009 at 5:13 pm
– Tip added by an anonymous user on Jan 14, 2009 at 9:47 am

Debugging Javascript

100% positive, 0 comments
– Tip added by an anonymous user on Sep 12, 2008 at 2:35 pm

compressing javascript

100% positive, 0 comments
– Tip added by an anonymous user on Jun 12, 2008 at 3:02 pm

attaching events to nodes in Javascript

no ratings, 0 comments
– Tip added by an anonymous user on Aug 18, 2008 at 11:23 am

animating elements with jQuery

0% positive, 0 comments
– Tip added by an anonymous user on Aug 04, 2008 at 1:46 pm