Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Beginning ASP.NET 4 : in C# and VB
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 21st, 2014, 09:43 PM
Registered User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in Chapter 3 Code or in my head?

I wouldn't write you except that I've been going over this code for three days. It matches every diddle and dot in the book example, but guess what: the panel doesn't appear when the checkbox is checked. (Yes, the checkbox's AutoPostback="true"). It's impossible for me to believe that nonfunctional code would have made it this far without being caught, but I've also gone over and over the code and everything (everything that I understand at least) seems perfect: the Protected Sub CheckBox1_CheckedChanged seems to run, but still ... no panel appears. Normally, I would not bother you with a problem like this, but it's *so* "clearly" the same code as in the book; yet it doesn't run. I'd really appreciate you having a look at it. Thanks, -Jeff

Code:
 Container.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Container.aspx.vb" Inherits="Container" %>
<!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" Text="Show Panel" />
 
      <asp:Panel ID="Panel1" runat="server" visible="false">
         I am visible now.
      </asp:Panel>

  </div> 
  </form>
</body>
</html>

-- Container.aspx.vb --

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Container.aspx.vb" Inherits="Container" %>
<!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" Text="Show Panel" />
 
      <asp:Panel ID="Panel1" runat="server" visible="false">
         I am visible now.
      </asp:Panel>

  </div> 
  </form>
</body>
</html>
Reply With Quote
  #2 (permalink)  
Old August 24th, 2014, 07:03 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

Hi there,

It looks like you posted the markup twice, instead of the code behind. Can you post the full code for the page again?

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!
Reply With Quote
  #3 (permalink)  
Old August 25th, 2014, 12:17 AM
Registered User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Yup, I posted the aspx.vb file twice and no aspx. Sorry.

Hi again Imar,

There goes my credibility! Well, I guess it comes from staring at the code too long. So here goes again. Starting with Containers.aspx:

Code:

Partial Class Containers
  Inherits System.Web.UI.Page

  Protected Sub CheckBox1_CheckedChanged(sender As Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
    Panel1.Visible = True
  End Sub

End Class
You'll notice that I changed the Boolean "Checkbox1.CheckedChanged" to its boiled-down equivalent: "True". Just an attempt to avoid anything that might be behind the problem, and I may have made similar tiny changes in other places. However, in both the standard ("in-your-book) version and in the boiled-down version, that Sub appears to have run, although ineffectively. Also, without thinking I named everything "Container" in the beginning and not "Containers." I changed back to "Containers," but there may be some hidden detritus from the renames that's currently inaccessible to me, given the state of my ignorance about ASP.NET.

Here (again) is the code for Containers.aspx.vb"

Code:

Partial Class Containers
  Inherits System.Web.UI.Page

  Protected Sub CheckBox1_CheckedChanged(sender As Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
    Panel1.Visible = True
  End Sub

End Class
I very much appreciate your patience (I didn't used to be a moron), and thanks again,

-Jeff Palley
JeffPalley@gmail.com

P.S. If it helps, I just noticed that if I make the default browser Chrome instead of IE, I get a little bit more when I check the checkbox ("I am visible now" appears, but the panel is still not visible).

Last edited by JeffPalley; August 25th, 2014 at 12:21 AM.. Reason: error in post
Reply With Quote
  #4 (permalink)  
Old August 25th, 2014, 07:58 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 get a little bit more when I check the checkbox ("I am visible now" appears, but the panel is still not visible).
That means it's working. The panel has no visual representation in this exercise, but it shows its contents.

Hope this helps,

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!
Reply With Quote
  #5 (permalink)  
Old August 25th, 2014, 10:08 AM
Registered User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default I sent you the wrong Containers.aspx file

... i.e., without the full panel code.

Here's the right Containers.aspx file ...

Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Containers.aspx.vb" Inherits="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" Text="Show Panel" />
 
      <asp:Panel ID="Panel1" runat="server" visible="False" Width="500px" >
        <asp:Wizard ID="Wizard1" runat="server" Width="500px" ActiveStepIndex="0">
          <WizardSteps>
            <asp:WizardStep runat="server" title="About You" ID="YourName">
              <asp:Label ID="YourNamex" runat="server" Text="Type your name"></asp:Label>
              <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </asp:WizardStep>
            <asp:WizardStep runat="server" title="Favorite Language">
              <asp:DropDownList ID="FavoriteLanguage" runat="server" AutoPostBack="True">
                <asp:ListItem>Visual Basic</asp:ListItem>
                <asp:ListItem>C#</asp:ListItem>
                <asp:ListItem>CSS</asp:ListItem>
              </asp:DropDownList>
            </asp:WizardStep>
            <asp:WizardStep runat="server" StepType="Complete" Title="Ready">
              Result
            </asp:WizardStep>
          </WizardSteps>
        </asp:Wizard>
      </asp:Panel>

  </div> 
  </form> 
</body>
</html>
This one works fine (with the default server being Chrome) until I press "Finish" ... at which point it displays a horrible mess of errors that probably makes sense to you, but not to me. I am very sorry that my errors are taking up so much of your time -- but it is highly apreciated.

Thanks,
-Jeff

P.S. Here's the Containers.aspx.vb file that goes with it:

[code]


Partial Class Containers
Inherits System.Web.UI.Page


Dim Result As Object

Protected Sub CheckBox1_CheckedChanged(sender As Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged
Panel1.Visible = True
End Sub

Protected Sub Wizard1_FinishButtonClick(sender As Object, e As System.Web.UI.WebControls.WizardNavigationEventArg s) _
Handles Wizard1.FinishButtonClick
Result.Text = "Your name is " & YourName.ID
Result.Text &= "<br />Your favorite language is " & FavoriteLanguage.SelectedValue
End Sub

Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load

End Sub


End Class

[\code]
Reply With Quote
  #6 (permalink)  
Old August 25th, 2014, 10: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

Hi there,

You may want to compare your code with mine, as there are a bunch of errors that will break things pretty badly (as you found out).

1. You renamed the label to YourName, not the TextBox (you also renamed it to YourNamex)

2. In the Complete step you should have a Label control with an ID of Result. Currently, you only have the word Result

3. In your code you're defining a new variable called Result of type Object; that is, you have this code:

Dim Result As Object

You should delete that, as Result should point to the Label from 2.)

4. In the Finish code, you access YourName.ID which returns the control's ID. You want to use YourName.Text instead to get the name the user entered.

There may be other errors but this should get you a long way fixing the issues. Feel free to post your next version of the code in case you keep getting errors.

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!
Reply With Quote
  #7 (permalink)  
Old August 25th, 2014, 11:46 AM
Registered User
Points: 33, Level: 1
Points: 33, Level: 1 Points: 33, Level: 1 Points: 33, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2014
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Astonished and humbled

Imar,

Thanks for your reply, which lists, in painfully polite detail, the 32,389 errors I made in 25 lines of code. I would tell you how many errors per line that comes to, but at this point I don't even trust myself to do division. You are astonishing, and I can't believe how polite you have been when replying to my CSS (cascading series of stupidities). You will not hear from me again until I reach chapter 10 at least ... my version of self-punishment (sort like abstaining from Imar for Lent).

The summary: you are amazing, and a blessing to the stupid.

Thank you 100 times for your perceptiveness, and thank you 1,000 times for your patient forbearance with me. The only positive thing I can think of (for you, not for me) is that other people's problems will now seem like minor absentmindedness in comparison. Or you can make a game of it: post my list of errors on your wall and throw darts at it: the larger the number you hit, the more points. Ask your friends over for beers and a goot time, but I would appreciate if you could leave my name off the list you post on the wall ... someday I might actually MEET one of your friends, maybe at an airport terminal somewhere, and I'd be embarrassed to watch them falling onto the floor, pointing their finger at me and laughing hysterically.

Have a good week, and may God bless you this week by keeping the idiots away from you for at least the next seven days.

-Jeff
Reply With Quote
  #8 (permalink)  
Old August 25th, 2014, 05:12 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

Haha, don't be too hard on yourself. You bought a beginner's book, didn't you? So isn't it expected to make beginners' mistakes?

Feel free to post follow up questions if you have them, even from chapters 6-9 ;-)

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!
Reply With Quote
Reply


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
Code Error Chapter 5 ostrandernw BOOK: Beginning Access 2007 VBA ISBN: 978-0-470-04684-5 3 January 30th, 2018 04:31 PM
Chapter 8 Listing 8-1 Code error remigiusa_s BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 1 July 2nd, 2010 02:12 PM
Chapter 15 Code Error - HELP! peterjstorey BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 5 January 24th, 2008 05:33 PM
Chapter 12 code error rsteph7 BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 34 August 18th, 2004 01:53 PM



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


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