Wrox Programmer Forums
| 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 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 November 19th, 2011, 09:54 AM
Registered User
Points: 59, Level: 1
Points: 59, Level: 1 Points: 59, Level: 1 Points: 59, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default Jquery Watermark Problem

hello

im having difficulty with the for watermark script, here is what is output onto the screen:


http://img525.imageshack.us/img525/8...zzzzzzzzzq.jpg


here is the markup:


<script type="text/javascript">

$(function () {
$(':input[type=text], textarea').each(function () {
var newText = 'Please enter your ' +
$(this).parent().prev().text();
$(this).attr('value', newText);
}).one('focus', function () {
this.value = '', this.className = ''
}).addClass('Watermark').css('width', '500px');



});

</script>

<p>
<td><span class="widelabel">Name:</span></td>
<td><asp:TextBox ID="nameTextBox" runat="server" /></td>
<br />
<td><span class="widelabel">User Name:</span></td>
<td><asp:TextBox ID="userNameTextBox" runat="server" /></td>
<br />
<td><span class="widelabel">Address:</span></td>
<td><asp:TextBox ID="addressTextBox" runat="server" /></td>
<br />
<td><span class="widelabel">City:</span></td>
<td><asp:TextBox ID="cityTextBox" runat="server" /></td>
<br />
<td><span class="widelabel">Zip:</span></td>
<td><asp:TextBox ID="zipTextBox" runat="server" /></td>
<br />
<td><span class="widelabel">Home Phone:</span></td>
<td><asp:TextBox ID="homePhoneTextBox" runat="server" /></td>
<br />
<td><span class="widelabel">Extension:</span></td>
<td><asp:TextBox ID="extensionTextBox" runat="server" /></td>
<br />
<td><span class="widelabel">Mobile Phone:</span></td>
<td><asp:TextBox ID="mobilePhoneTextBox" runat="server" /></td>
<br />
</p>
<p>
 
Old November 19th, 2011, 03:51 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

Hmmm, not sure what's going on. I compared your code with that from the book and besides some whitespace and the width, I don't see a difference.

Which browser did you test this on? Have you tried another?

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!
The Following User Says Thank You to Imar For This Useful Post:
ftaran (November 19th, 2011)
 
Old November 19th, 2011, 03:57 PM
Registered User
Points: 59, Level: 1
Points: 59, Level: 1 Points: 59, Level: 1 Points: 59, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2011
Posts: 14
Thanks: 5
Thanked 0 Times in 0 Posts
Default

hi, i fixed that problem but, i need the jquery to only apply on the first load of the page, is there a function for that?
the reason is that when a user selects a name the details are obtained using that name's ID and appended to the textboxes, but because the jquery applies to all the text boxes each time the page loads after the user selects a name the 'please enter etc' is replacing the data obtained from the database after the click and post back of the button.
 
Old November 19th, 2011, 04:13 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

It depends on how you implement it. If your markup is wrapped in an UpdatePanel, the jQuery code won't fire after a post back.

You could also wrap your jQuery code in a PlaceHolder and then toggle its visibility in the Code Behind, or register the jQuery code programmatically.

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!
The Following User Says Thank You to Imar For This Useful Post:
ftaran (November 19th, 2011)




Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with jquery ch 11 nzg5 BOOK: Beginning ASP.NET 4 : in C# and VB 16 February 25th, 2012 10:49 PM
jQuery Watermark Plugin Phil Critchley BOOK: Beginning ASP.NET 4 : in C# and VB 11 November 24th, 2011 12:06 PM
Using the Watermark vbboyd BOOK: Beginning ASP.NET 4 : in C# and VB 2 May 26th, 2011 12:17 AM
Problem in IE 8 With Newer Versions of jQuery tknyc BOOK: Beginning JavaScript and CSS Development with jQuery 1 April 13th, 2011 02:32 PM
Problem with jquery ch 11 nzg5 BOOK: Beginning ASP.NET 4 : in C# and VB 1 October 4th, 2010 11:57 AM





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