Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-31180-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5 : in C# and VB 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
 
Old November 29th, 2013, 05:49 PM
Authorized User
 
Join Date: Mar 2011
Posts: 19
Thanks: 11
Thanked 0 Times in 0 Posts
Question Where am I going wrong

Hi I have just restarted practising vb express 13 after a long illness all seemed to be working until I started the containers exercise agail all seemed to be going well until I did the wizard about you
favourite Language and result. the code : Result.Text &= "<br />Your favourite Language is " & Favoritelanguage.selectedValue does not work and I get an error notice that it is not part of the wizzard steps ?
 
Old November 29th, 2013, 06:06 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Hope you're feeling better!

Can you post the code of the ASPX file and its code behind?

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!
 
Old November 29th, 2013, 06:38 PM
Authorized User
 
Join Date: Mar 2011
Posts: 19
Thanks: 11
Thanked 0 Times in 0 Posts
Default

Protected Sub Wizard1_FinishButtonClick(sender As Object, e As WizardNavigationEventArgs) Handles FavoriteLanguage.FinishButtonClick
Result.Text = "Your name is " & yourname.Text
Result.Text &= "<br />Your Favorite language is " & FavoriteLanguage.SelectedValue
Protected Sub Wizard1_FinishButtonClick(sender As Object, e As WizardNavigationEventArgs) Handles FavoriteLanguage.FinishButtonClick
Result.Text = "Your name is " & yourname.Text
Result.Text &= "<br />Your Favorite language is " & FavoriteLanguage.SelectedValue
 
Old November 29th, 2013, 06:40 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This is just the code behind and not the markup so there may also be other issue but one thing that stands out is this:

Code:
Result.Text = "Your name is " & yourname.Text
This resets the Text property, effectively overwriting the text from the previous lines of code. The following should fix it:

Code:
Result.Text &= "Your name is " & yourname.Text
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:
tommykehoe (December 1st, 2013)
 
Old December 1st, 2013, 08:27 AM
Authorized User
 
Join Date: Mar 2011
Posts: 19
Thanks: 11
Thanked 0 Times in 0 Posts
Default where Have I gone wrong

Hi Imar I still have not solved this problem
<form id="form1" runat="server">
<div>

<asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" Text="Show Panel" OnCheckedChanged="CheckBox1_CheckedChanged" />
<asp:Panel ID="Panel1" runat="server" Visible="False">
<asp:Wizard ID="FavoriteLanguage" 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="yourname" runat="server"></asp:TextBox>
</asp:WizardStep>
<asp:WizardStep runat="server" title="Favorite Language" StepType="Finish">

<asp:DropDownList ID="favouriteLanguage" runat="server">
<asp:ListItem>C#</asp:ListItem>
<asp:ListItem>Visual Basic</asp:ListItem>
<asp:ListItem>Css</asp:ListItem>
</asp:DropDownList>

</asp:WizardStep>
Protected Sub Wizard1_FinishButtonClick(sender As Object, e As WizardNavigationEventArgs) Handles FavoriteLanguage.FinishButtonClick
Result.Text = "Your name is " & yourname.Text
Result.Text &= "<br />Your Favorite language is " & FavoriteLanguage.SelectedValue

End Sub
Sorry for being a nusience But I am determined to do this and will carry on with the rest of the exercises. Thank you
 
Old December 1st, 2013, 11:42 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I think you confused yourself a bit with the control names. You named the wizard FavoriteLanguage and the drop down favouriteLanguage. The ID of the wizard doesn't matter (and isn't used in code), but the drop down's ID is important as you access it in code to get its selected value. However, your code tries to access the wizard instead. SO this:

Code:
Result.Text = "Your name is " & yourname.Text
Result.Text &= "<br />Your Favorite language is " & FavoriteLanguage.SelectedValue
should be this:
Code:
Result.Text = "Your name is " & yourname.Text
Result.Text &= "<br />Your Favorite language is " & favouriteLanguage.SelectedValue
When you post code here, can you paste it in Notepad first to get rid of the color coding and then use the Code button on the toolbar (#) to format your code? That makes it a lot easier to read.

Thanks,

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!
 
Old December 1st, 2013, 04:38 PM
Authorized User
 
Join Date: Mar 2011
Posts: 19
Thanks: 11
Thanked 0 Times in 0 Posts
Default where did I go wrong

Thank you Imar I will retry to do it again





Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this worded wrong or am I reading wrong? notig BOOK: Beginning Visual C# 2010 1 September 25th, 2010 01:51 PM
Am I doing something wrong? devTed BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 2 February 1st, 2009 10:17 AM
what am I doing wrong? dabbler PHP Databases 6 August 13th, 2008 09:27 AM
Where did I go wrong??? ahc2inc VB.NET 2002/2003 Basics 3 September 28th, 2004 08:19 PM





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