Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 31st, 2012, 01:06 PM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help - Javascript fro Watermark

Can anyone please help correct some Javascipt? This particular script is not in the download.... it is in Chapter 11.

When I run the script, I get:

Error: '$' is undefined in the browser. (How can it be undefined??)

The code is below and seems identical to the code in the book - but I am willing to bet it has a glitch I have not found yet.

Code:
<%--Java Script to apply Watermark --%>
<script type="text/javascript">
     $(function() 
     {
          $(':input[type=text],textarea').each
          (
          function() 
          {
               var newText = 'Please enter your ' +
               $(this).parent().prev().text().toLowerCase().trim();
               $(this).attr('value', newText); 
          }).one('focus', function() 
                    {    
                         this.value = '', this.className = ''
                              }).addClass('Watermark').css('width', '300px');
     });
</script>

Last edited by pgrant; March 31st, 2012 at 01:10 PM..
Reply With Quote
  #2 (permalink)  
Old March 31st, 2012, 01:17 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

The error "Error: '$' is undefined in the browser." seems to imply the jQuery library cannot be found. Did you add a reference to it in your page or master page? Can you show the code for that and describe where you placed the jQuery library .js file?

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote
  #3 (permalink)  
Old March 31st, 2012, 02:37 PM
Registered User
Points: 20, Level: 1
Points: 20, Level: 1 Points: 20, Level: 1 Points: 20, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Thank You

Imar
Thanks you are quite right, no reference. I was trying to test my understanding by putting subjects in the book into my own web site - and I missed an important step.
Reply With Quote
Reply


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
javscript for allow enter key only in multilne textboxes sudhi ASP.NET 1.0 and 1.1 Professional 1 August 13th, 2011 09:53 AM
need to fix the size of page opened via javscript. satish.srivastava@igt.in JSP Basics 0 August 10th, 2010 07:14 AM
VBscript boolean function causes Javscript to bomb calgarychinese Javascript 2 August 25th, 2008 03:38 PM
Javscript works well in aspx page but fails... vivek_inos ASP.NET 1.0 and 1.1 Professional 2 June 18th, 2006 11:26 PM
Masterpage to include a javscript file whatagamble ASP.NET 2.0 Basics 0 March 19th, 2006 01:09 PM



All times are GMT -4. The time now is 11:27 AM.


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