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: ASP.NET 3.5 Website Programming Problem Design Solution
This is the forum to discuss the Wrox book ASP.NET 3.5 Website Programming Problem Design Solution by Chris Love; ISBN: 978-0-470-18758-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Website Programming Problem Design Solution 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
 
 
Thread Tools Search this Thread Display Modes
  #21 (permalink)  
Old June 21st, 2010, 03:22 AM
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

Ah, while typing my reply, your second post came in with the jQuery code.

A few things:

1. In your initial HTML, there's no jQuery code, so are you sure the page is referencing the correct master page? Do you see the jQuery code end up in the final page in the browser?

2. Try to make this work without a master page first. Master pages make working with client side controls more difficult. The problem may be in the client IDs or somewhere else, so by using a normal page you can eliminate some of the problems for now.

3. Please use the Wrap Code button on the toolbar when posting code to make the code you post easier to read.

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!
  #22 (permalink)  
Old June 21st, 2010, 03:23 AM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

That was the complete example. I actually see both, but, you just said you see the first dropdown value only! Can you tell me how you came up with that conclusion?
  #23 (permalink)  
Old June 21st, 2010, 03:25 AM
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

I posted that because I hadn't seen your second post with the jQuery code. All I saw was this:

Code:
 
var employees = new Employee();
ddlEmployee.DataSource = employees.FetchEmployees();
ddlEmployee.DataTextField = "Surname";
ddlEmployee.DataValueField = "Id";
ddlEmployee.DataBind();
which adds items to the first drop down list. I didn't see the client side code that's supposed to add the items to the second control as you hadn't posted that yet when I started my reply.

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!
  #24 (permalink)  
Old June 21st, 2010, 03:32 AM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I see what you mean now!

I just followed the example and didn't notice example probably had that missing.

EmployeeCar variable needs to be instantiated and ddlEmployeeCar needs values. I'll try that and let's see what happens.

Like I said without placing the code in Masterpage, I get error......
  #25 (permalink)  
Old June 21st, 2010, 03:43 AM
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

Quote:
Like I said without placing the code in Masterpage, I get error......
But you should be able to place the code in the Content Page, in a ContentPlaceHolder that ends up in the head of the page. E.g. in your master:

Code:
 
<head>
...
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
...
</head>
And then in the Content Page:

Code:
 
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
  Code from master here
</asp:Content>
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!
  #26 (permalink)  
Old June 21st, 2010, 04:11 AM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I think the code isn't missing in the original example, it's intentionally like that since in EmployeeCars is already in the webmethod and page_load should probably have only Employees code, shouldn't it?

I can instantiate var employeeCars = new EmployeeCar();
But, not --> ddlEmployeeCars.DataSource = employeeCars.FetchEmployeeCars();

I get error that no overload for method FetchEmployeeCars()

I guess it's already defined static in the webMethod!


Thanks,
Kaiser
  #27 (permalink)  
Old June 21st, 2010, 04:13 AM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Here's the link to actual example I'm getting codes from:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=417
  #28 (permalink)  
Old June 21st, 2010, 04:21 AM
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

Quote:
I think the code isn't missing in the original example,
I was referring to the jQuery code in the master page. You posted the code for the content page at 09:10 AM and for the master at 09:16 AM. I started my reply at 09:13 AM and thus never saw the code you posted for the master page. Since the master in your case contains the code that tries to fill the second drop down list, I throught there was no code that tries to fill that list.

Quote:
it's intentionally like that since in EmployeeCars is already in the webmethod and page_load should probably have only Employees code, shouldn't it?
This sentence makes no sense to me.
Quote:
I get error that no overload for method FetchEmployeeCars()
I think that makes sense, as that method expects an integer id.

I've seen the example (as I sent that link to you), but that's of no use here. I am sure that code works or otherwise the article would have been updated. It's the code in your project that's relevant here. Did you follow my suggestions by using a page without a master page? And what happens when you debug your code? Do things get called correctly? E.g. does the client side jQuery code correctly call the static web method?

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!
  #29 (permalink)  
Old June 21st, 2010, 05:12 PM
Authorized User
 
Join Date: Apr 2010
Location: Seattle, WA
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
Default

I moved the code out of the masterpage to default.aspx. Now it works! Why it didn't work when JQuery code was in the Masterpage that's beyond me!

But, if I were to expand the application, or the application gets too big, I have to use the Masterpage anyway. So, how'd that work then if things from Masterpage doesn't work?

Two more issues though!

I want to expand to one more level of dropdown like EmployeeCarColor. How do I do that? I know I have to create another class EmployeeCarColors.cs. What do I bind it to ddlEmployeeCars?

We discussed in the earlier posting I can get the data from an XML file. Do you have any example or tutorial on that for getting data from ASP.net+C# app to XML.
  #30 (permalink)  
Old June 21st, 2010, 05:36 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,

1) You need to repeat more or less what you have now. E.g. react to the index changed of the drop down list and call a web method for the third list.

2) I don't have one handy, but Google does: http://www.google.com/#hl=en&source=...08032baa5e4530

When you use master pages the client side IDs of controls change so your jQuery code can no longer find the right controls. You can use the control's CllientID to get its (changed) ID at the client. Again, Google knows more: http://www.google.com/#hl=en&q=maste...08032baa5e4530

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:
krahman01 (June 21st, 2010)
 


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
Dropdown list maha .NET Framework 2.0 7 April 28th, 2007 12:32 AM
Dropdown list with multiple selections tombert ASP.NET 1.0 and 1.1 Basics 15 March 7th, 2007 07:38 PM
fill dropdown list with items when parent list isaac_cm Pro PHP 1 July 10th, 2006 05:41 AM
Storing multiple values from the dropdown list lily611 SQL Server 2000 0 June 21st, 2004 06:08 AM
Storing multiple values from the dropdown list lily611 ADO.NET 0 June 21st, 2004 05:21 AM



All times are GMT -4. The time now is 11:25 PM.


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