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, 4 total Votes
Categories: programming ASP .Net javascript
Added: on May 05, 2007 at 7:00 am
Added By: an anonymous user

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

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

Setting the button triggered by the enter key

Categories: programming ASP .Net web
no ratings, 0 comments
– Tip added by an anonymous user on Jun 05, 2007 at 6:09 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

Static variables in Javascript

100% positive, 2 comments - last added on May 08, 2008 at 4:19 pm
– Tip added by an anonymous user on Aug 03, 2007 at 4:19 pm

Scrolling HTML elements using the keyboard

100% positive, 0 comments
– Tip added by rlansky on Jun 22, 2007 at 9:34 am

Trimming whitespace in Javascript

Categories: javascript programming
100% positive, 0 comments
– Tip added by an anonymous user on Sep 13, 2007 at 1:54 pm

Great AJAX repository

100% positive, 0 comments
– Tip added by hindy on May 02, 2007 at 7:23 am

Javascript Error: unterminated regular expression literal

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

compressing javascript

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

Telling when an iframe is done loading

100% positive, 0 comments
– Tip added by an anonymous user on Apr 18, 2008 at 8:05 am

Hex colors in System.Drawing

Categories: ASP .Net web
100% positive, 1 comment - last added on May 27, 2007 at 8:18 pm
– Tip added by an anonymous user on May 25, 2007 at 8:44 am

Creating vector graphics in javascript

100% positive, 0 comments
– Tip added by Marcos84 on May 10, 2007 at 2:44 pm

Javascript: How to Create a Random Number

0% positive, 0 comments
– Tip added by Walkere on Feb 23, 2008 at 9:49 pm

Javascript variable naming

no ratings, 0 comments
– Tip added by an anonymous user on Sep 30, 2007 at 7:28 am

Code for creating Javascript CSS charts

no ratings, 0 comments
– Tip added by an anonymous user on Aug 21, 2007 at 12:23 pm

Efficient building of large strings in Javascript

no ratings, 0 comments
– Tip added by an anonymous user on Aug 08, 2007 at 12:52 pm

Avoid invalid title names when opening javascript windows

no ratings, 0 comments
– Tip added by an anonymous user on Aug 07, 2007 at 9:36 am

Nice article on javascript techniques

no ratings, 0 comments
– Tip added by rlansky on Apr 24, 2007 at 8:12 am