Wrox Programmer Forums
|
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 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 August 15th, 2011, 10:25 AM
Authorized User
 
Join Date: Feb 2011
Posts: 23
Thanks: 7
Thanked 0 Times in 0 Posts
Default Watermark works on only one field

Page 387 Try It Out Step 3

The watermark is working for the Comments field but not for the other five

Just FYI at the bottom of step three it says "If you don't feel like typing all this code, remember you can get a copy of it from the code download that goes with the book." but the code in step three isn't in the download.

Here is the current version of my code:
<style type="text/css">
.style1
{
width: 100%;
}
.style2
{
height: 31px;
margin-left: 40px;
}
.Watermark
{
font-style: italic;
color: Gray;
}
</style>

</asp:UpdateProgress>
<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>
 
Old August 15th, 2011, 10:29 AM
Authorized User
 
Join Date: Feb 2011
Posts: 23
Thanks: 7
Thanked 0 Times in 0 Posts
Default

From the View Source:

<tr>
<td>
Business phone number</td>
<td>
<input name="ctl00$cpMainContent$ContactForm1$PhoneBusine ss" type="text" id="cpMainContent_ContactForm1_PhoneBusiness" />
</td>

<td>
&nbsp;</td>
</tr>
<tr>
<td>
Comments</td>
<td>
<textarea name="ctl00$cpMainContent$ContactForm1$Comments" rows="2" cols="20" id="cpMainContent_ContactForm1_Comments" style="height:72px;width:397px;">

</textarea>
</td>
<td>
<span id="cpMainContent_ContactForm1_RequiredFieldValida tor4" class="ErrorMessage" style="display:none;">Enter a comment</span>
</td>
</tr>
<tr>
 
Old August 15th, 2011, 10:33 AM
Authorized User
 
Join Date: Feb 2011
Posts: 23
Thanks: 7
Thanked 0 Times in 0 Posts
Default

Just noticed the resizing is not working for the first five fields either.
 
Old August 15th, 2011, 10:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
"If you don't feel like typing all this code, remember you can get a copy of it from the code download that goes with the book."
I think that's actually a "bug" in the book ;-) The code was there initially, but it's being replaced by a watermark plugin later in the chapter. Since the downloads contains the state of the application at the end of each chapter, this code isn't there. Anyway, the issue might be in this:

Code:
 
   $(':input[type-text], textarea').each
It's type=text as you're filtering input controls whose type is text. For you reference, here's the complete code from the book:

Code:
 
<script type="text/javascript">
$(function()
{
  $(':input[type=text], textarea').each
  (
    function()
    {
      var newText = 'Please enter your ' + $(this).parent().prev().text().toLowerCase().trim();
      var$(this).attr('value', newText);
    }).one('focus', function()
    {
      this.value = '', this.className = ''
    }).addClass('Watermark').css('width', '300px');
  });
</script>
__________________
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!
The Following User Says Thank You to Imar For This Useful Post:
floridaguy (August 15th, 2011)
 
Old August 15th, 2011, 10:52 AM
Authorized User
 
Join Date: Feb 2011
Posts: 23
Thanks: 7
Thanked 0 Times in 0 Posts
Default

That solved the problem. Thanks for the great support!





Similar Threads
Thread Thread Starter Forum Replies Last Post
jQuery Watermark Plugin Phil Critchley BOOK: Beginning ASP.NET 4 : in C# and VB 11 November 24th, 2011 12:06 PM
Watermark not working floridaguy BOOK: Professional ASP.NET 4 : in C# and VB 2 August 15th, 2011 10:19 AM
Using the Watermark vbboyd BOOK: Beginning ASP.NET 4 : in C# and VB 2 May 26th, 2011 12:17 AM
Watermark image amirmunir Crystal Reports 0 June 1st, 2006 12:09 PM
Insert text as watermark in the report? pallavijyo BOOK: Professional Crystal Reports for VS.NET 0 December 15th, 2004 10:14 AM





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