 |
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 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
|
|
|
|
|

June 21st, 2010, 03:22 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 21st, 2010, 03:23 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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?
|
|

June 21st, 2010, 03:25 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 21st, 2010, 03:32 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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......
|
|

June 21st, 2010, 03:43 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 21st, 2010, 04:11 AM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 21st, 2010, 04:21 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 21st, 2010, 05:12 PM
|
|
Authorized User
|
|
Join Date: Apr 2010
Posts: 50
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 21st, 2010, 05:36 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|
 |