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 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>
Reply With Quote
  #2 (permalink)  
Old November 19th, 2011, 03:51 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

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!
Reply With Quote
The Following User Says Thank You to Imar For This Useful Post:
ftaran (November 19th, 2011)
  #3 (permalink)  
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.
Reply With Quote
  #4 (permalink)  
Old November 19th, 2011, 04:13 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

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



All times are GMT -4. The time now is 02:33 PM.


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