Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Professional Ajax ISBN: 978-0-471-77778-6
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Ajax ISBN: 978-0-471-77778-6
This is the forum to discuss the Wrox book Professional Ajax by Nicholas C. Zakas, Jeremy McPeak, Joe Fawcett; ISBN: 9780471777786
Important: For the new 2nd edition of this book, please post here instead: [url="http://p2p.wrox.com/forum.asp?FORUM_ID=307"]http://p2p.wrox.com/forum.asp?FORUM_ID=307[/url]
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Ajax ISBN: 978-0-471-77778-6 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
  #1 (permalink)  
Old July 3rd, 2006, 09:37 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Converting AutoSuggest textbox to .NET UserControl

Hi im trying to convert the AutoSuggest Textbox to a .NET Usercontrol, but im getting the following error

A Runtime Error has occurred. Do you wish to Debug?
Line: 107
Error: Object required

The error happens when im typing something in the Textbox and comes from my AutoSuggest.js file

while(oNode.tagName != "BODY") {
        iLeft += oNode.offsetLeft;
        oNode = oNode.offsetParent;
    }

In the following link is the html code that my applikation generates
http://www.gulbaek.net/tmp/AutoSuggest.zip

Hope someone can help solve this problem.

And one final question, is the someway to include the .js files in the UserControl, my current solution is to include the following code in my MasterPage

<head runat="server">
    <title></title>
    <script type="text/javascript" src="UserControl/AutoSuggest.js"></script>
    <script type="text/javascript" src="UserControl/Suggestions.js"></script>
</head>

  #2 (permalink)  
Old July 3rd, 2006, 09:41 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I'm guessing that you're probably running your code in standards mode. Try making this change:

Code:
while(oNode && oNode.tagName != "BODY") {
       iLeft += oNode.offsetLeft;
       oNode = oNode.offsetParent;
}
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
  #3 (permalink)  
Old July 3rd, 2006, 09:49 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks that did the work, though i had to chance the code in both the getLeft and getTop functions.

What do you mean with running my code in standards mode, and is it posible to move the
<script type="text/javascript" src="UserControl/AutoSuggest.js"></script>
    <script type="text/javascript" src="UserControl/Suggestions.js"></script>

code inside my User Control?

  #4 (permalink)  
Old July 3rd, 2006, 09:51 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I'm sorry, I don't know much about .NET architecture, so I can't really tell you if you can move that code inside of your control.

What I mean by standards mode is by setting an XHTML doctype, you put the browser into standards mode, which makes JavaScript behave slightly differently.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
  #5 (permalink)  
Old July 3rd, 2006, 10:00 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ohh thanks, just one more question, do you know why the typeAhead function is'nt working now, no errors nothing just happens only the list of suggestions is displayed.

  #6 (permalink)  
Old July 3rd, 2006, 10:20 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

It's impossible to know that's wrong simply from that description. It's the same as saying "hey, my TV won't turn on, do you know why?". :)

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
  #7 (permalink)  
Old July 3rd, 2006, 10:30 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes I know but its really difficult to debug a java script, so I can't see whats happening.
Just belived it has someting to do with the fact that im running in XHTML mode, just like your solution to my first problem.

  #8 (permalink)  
Old July 3rd, 2006, 10:36 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

So you can imagine how hard it is for me to try to figure out what is going wrong with your script when you're having trouble. If you can trace the problem to something specific, post the details and we can try to work through it.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/


Similar Threads
Thread Thread Starter Forum Replies Last Post
Addition of Textbox in a UserControl rhd110 General .NET 0 July 12th, 2007 06:05 AM
Prevent converting empty textbox string to date. fizzerchris ASP.NET 2.0 Basics 2 May 18th, 2007 06:52 PM
Autosuggest Textbox by Nicholas Zakas smay Javascript 5 January 13th, 2006 07:45 AM
Autosuggest Textbox Issue smay Javascript 3 August 3rd, 2005 02:25 PM
Event in an ASP.NET 2 usercontrol bmains ASP.NET 2.0 Basics 1 February 25th, 2005 03:28 PM





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