 |
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
 | This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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
|
|
|
|
|

March 5th, 2009, 01:26 AM
|
|
Registered User
|
|
Join Date: Mar 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Pg. 122
Just picked the book up and am working through it.
Not getting the result I am supposed to on page 122
Here is the code for that file
Code:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
Panel1.Visible = CheckBox1.Checked;
}
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
lblResult.Text = "Your name is " + txtName.Text;
lblResult.Text += "<br />Your favorite language is " + lstFavoriteLanguage.SelectedValue;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True"
oncheckedchanged="CheckBox1_CheckedChanged" Text="Show Panel" />
<asp:Panel ID="Panel1" runat="server" Visible="False">
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" Width="500px">
<WizardSteps>
<asp:WizardStep runat="server" title="About You">
<asp:Label ID="Label1" runat="server" Text="Type your name"></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</asp:WizardStep>
<asp:WizardStep runat="server" title="Favorite Language" StepType="Finish">
<asp:DropDownList ID="lstFavoriteLanguage" runat="server">
<asp:ListItem>#C</asp:ListItem>
<asp:ListItem>Visual Basic</asp:ListItem>
<asp:ListItem>CSS</asp:ListItem>
</asp:DropDownList>
</asp:WizardStep>
<asp:WizardStep runat="server" StepType="Complete" Title="Ready">
<asp:Label ID="lblResult" runat="server"></asp:Label>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</asp:Panel>
</div>
</form>
</body>
</html>
Not getting results of entered information in the label lblResults
Thanks
Cameront21
|
|

March 5th, 2009, 03:40 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi there,
There are a few things wrong with the code.... First of all, you are using in-line code while the book consistently uses Code Behind. Not a major problem for this exercise, but it vwill be for later parts.
Secondly, you seem to be missing the FinishButtoinClick handler in the Wizard. It should read:
<asp:Wizard ID="Wizard1" runat="server" Width="500px" ActiveStepIndex="0"
OnFinishButtonClick="Wizard1_FinishButtonClick">
The handler should have been added by double-clicking the Wizard in step 8.
Hope this helps,
Imar
|
|

January 15th, 2010, 10:49 AM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 14
Thanks: 4
Thanked 1 Time in 1 Post
|
|
Sorry Imar, for raising this yet again.
Just working through the book and I have come across the same problem. I can create the Wizard OK, and the DDL OK, but once I try to edit the DDL as instructed nothing happens. I have made repeated attempts to succeed but at last I have to admit defeat.
As I could not create the contents of the DDL by using the 'Edit Items' option I added some items manually direct to the code. That worked Ok with no problems. Then, trying to add more items using the 'Edit Items' method I failed again.
Can't find any other thing to try. As a further check I went back and revisited the 'ListControls' demo and it all worked fine.
There seems to be an issue when inserting within the Wizard as far as I can deduce, as I can use the 'Edit List' method successfully elsewhere on the page.
Interesting to note that your code snippet read ...
Code:
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" title="Favorite Language" StepType="Finish">
<asp:DropDownList ID="lstFavoriteLanguage" runat="server">
... whereas I can see no reference to the Wizard ID in my code. (I got the same code as Rachel posted in the chapter 4, problem with step wizard thread.) Is it possible that this is a cause of problems? I did add the ID info to the Wizard but got no further forward.
Last edited by Alanrf; January 15th, 2010 at 11:07 AM..
|
|

January 15th, 2010, 05:56 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Alanrf,
Can you post the code for the entire page? Also, can you explain in more detail how you;re trying to edit the DDL items? Does adding items in another page work?
Imar
|
|

January 16th, 2010, 07:55 AM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 14
Thanks: 4
Thanked 1 Time in 1 Post
|
|
Hi Imar,
Added the DDL code exactly as in book, page 112. This method worked perfectly OK for the ListControls.aspx demo
It is also possible, using the same method, to add a DDL to the Containers.aspx page as long as it is outside the Wizard. However, for some reason, (probably my own ineptitude), this method does not appear to work inside the Wizard.
The correct
Code:
<asp:DropDownList ID="lstFavoriteLanguage" runat="server">
</asp:DropDownList>
fragment is generated but attempting to add the content fails.
My current code for Containers.aspx is
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Containers.aspx.cs" Inherits="Demos_Containers" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True"
oncheckedchanged="CheckBox1_CheckedChanged" Text="Show Panel" />
<br />
<br />
<asp:Panel ID="Panel1" runat="server" Visible="False"
style="margin-bottom: 17px">
<asp:Wizard ID="Wizard1" runat="server" Width="500px" ActiveStepIndex="1"
onfinishbuttonclick="Wizard1_FinishButtonClick">
<%-- WizardStep ID entries made to replicate example in book--%>
<WizardSteps>
<asp:WizardStep runat="server" title="About you" ID="WizardStep1">
<asp:Label ID="Label1" runat="server" Text="Enter your name: "></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</asp:WizardStep>
<asp:WizardStep runat="server" title="Favorite Language" ID="WizardStep2"
StepType="Finish">
<asp:DropDownList ID="lstFavoriteLanguage" runat="server">
<%--These three lines added manually--%>
<asp:ListItem>C#</asp:ListItem>
<asp:ListItem>CSS</asp:ListItem>
<asp:ListItem>Visual Basic</asp:ListItem>
</asp:DropDownList>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server" StepType="Complete"
Title="Ready">
<asp:Label ID="lblResult" runat="server" Text="Label"></asp:Label>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</asp:Panel>
</div>
</form>
</body>
</html>
The code behind file is
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Demos_Containers : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
Panel1.Visible = CheckBox1.Checked;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
lblResult.Text = "Your name is: " + txtName.Text;
lblResult.Text += "<br /><br />Favorite Language is: " + lstFavoriteLanguage.SelectedValue;
}
}
Thanks for your help and interest.
__________________
Alan.
|
|

January 16th, 2010, 09:20 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Alan,
Are you sure you're doing this in Design View with the correct WizardStep active? I copied and pasted your code in a new web form and it works right away, as can be seen here:
http://imar.spaanjaars.com/Downloads...DesignView.png
Can you define "this method does not appear to work inside the Wizard"? Do you get an error? Is the DDL invisible? Is there no Smart Tasks button? Is there no Edit Items option? Etc etc....
Cheers,
Imar
|
|

January 16th, 2010, 12:05 PM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 14
Thanks: 4
Thanked 1 Time in 1 Post
|
|
Hi Imar,
I suspect that we are at cross purposes here. The code certainly works, because it was copied from a working page. The problem was that having created a DDL, as per my previous post, using the 'Smart Task' button had no effect.
What I did was to create the DDL, as per the text; there was no problem at that point.
Then, in Design View, I moused over the DDL and clicked the Smart Tasks tag. This brought up the Edit Items option which, in turn, brought up the ListItem Collection Editor.
This then allowed me to Add new items, (as you can see on your screen shot), which, although it appeared to work correctly, did not insert any code in the markup.
If I entered the code manually, as in my posted example, and then returned to Design View, I could then return to the DDL and click the Smart Task tag to return to Edit Items. The items that I had added manually showed up correctly, (as in your screen shot), as you would expect. If I then clicked Add to insert another item and then OK'd out, the new item was not added to the code.
However, if I repeated the exercise from scratch, on an 'empty' part of the page, (outside the wizard), I could do everything with no problem.
All very strange.
Perhaps you would care to try the code as it appeared before I added the content manually:
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Containers.aspx.cs" Inherits="Demos_Containers" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True"
oncheckedchanged="CheckBox1_CheckedChanged" Text="Show Panel" />
<br />
<br />
<asp:Panel ID="Panel1" runat="server" Visible="False"
style="margin-bottom: 17px">
<asp:Wizard ID="Wizard1" runat="server" Width="500px" ActiveStepIndex="1"
onfinishbuttonclick="Wizard1_FinishButtonClick">
<%-- WizardStep ID entries made to replicate example in book--%>
<WizardSteps>
<asp:WizardStep runat="server" title="About you" ID="WizardStep1">
<asp:Label ID="Label1" runat="server" Text="Enter your name: "></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
</asp:WizardStep>
<asp:WizardStep runat="server" title="Favorite Language" ID="WizardStep2"
StepType="Finish">
<asp:DropDownList ID="lstFavoriteLanguage" runat="server">
</asp:DropDownList>
</asp:WizardStep>
<asp:WizardStep ID="WizardStep3" runat="server" StepType="Complete"
Title="Ready">
<asp:Label ID="lblResult" runat="server" Text="Label"></asp:Label>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</asp:Panel>
</div>
</form>
</body>
</html>
Thanks for your continuing assistance.
__________________
Alan.
|
|

January 17th, 2010, 05:27 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Alan,
This sounds like an issue with Visual Studio / Visual Web Developer Express. What version are you using excactly? Are you using an English version? Did you apply Service Pack 1? If you haven't, it might be worth trying. If you have, I think this is a bug in VS. You could report it to Microsoft if you want: connect.microsoft.com.
I can successfully copy and paste your code and use it as explained in the book; e.g. adding items really adds them to markup as well so it must be something with your site or installation. You can, however, ignore this if you want to and simply add items through Markup View.
Cheers,
Imar
|
|
The Following User Says Thank You to Imar For This Useful Post:
|
|
|

January 17th, 2010, 08:22 AM
|
|
Authorized User
|
|
Join Date: Jan 2010
Posts: 14
Thanks: 4
Thanked 1 Time in 1 Post
|
|
Hi Imar,
Thanks for your response. I had, reluctantly, come to the same conclusion as you, that there may be some issue with Visual Web Developer Express.
As far as I am aware, I am up to date, and, at the risk of boring you and any other readers, I have appended details of my 'current' version, running on a Vista box, below.
In the meantime, as I have already discovered, and as you remark, it is a simple matter to code direct to the markup page. It is an interesting anomaly, because if the DDL is added anywhere other than in the wizard everything works correctly.
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
Installed Edition: WD Express
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB945282) KB945282
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB946040) KB946040
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB946308) KB946308
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB946344) KB946344
This hotfix is for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU.
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB946581) KB946581
This hotfix is for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU.
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB947540) KB947540
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB947789) KB947789
This hotfix is for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU.
Hotfix for Microsoft Visual Web Developer 2008 Express Edition with SP1 - ENU (KB951708) KB951708
__________________
Alan.
|
|

January 17th, 2010, 08:37 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Yep, that looks pretty up-to-date to me too.... ;-)
Imar
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Possible typo on pg 233 |
WebDNA |
BOOK: Ivor Horton's Beginning Visual C++ 2008 ISBN: 978-0-470-22590-5 |
1 |
October 15th, 2008 12:21 PM |
|
 |