Wrox Programmer Forums
|
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 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 December 7th, 2011, 03:49 AM
Registered User
 
Join Date: Dec 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Page 90, curly brackets

I followed the book step by step. On page 90, I am requested to enter the curly brackets { } and enter some info. like the date/time command. The curly brackets are not working only the <> are working. What am I doing wrong?
 
Old December 7th, 2011, 03:56 AM
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,

As I hinted in my personal e-mail on the same subject, please be more specific and provide more relevant information. For example, which language did you choose? Can you post the code for the entire page? What does "does not work" mean exactly? Do you get an error and if so, which one?

Without this kind of information, there's not much I can do. The code in the book is OK, so it must be something else....

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 December 7th, 2011, 04:12 AM
Registered User
 
Join Date: Dec 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using c#on aspx with visual web developer 2010 express. This is the code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Codebehind.aspx.cs" Inherits="Demos_Codebehind" %>

<!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="form2" runat="server">

<label accesskey onmouseover

<form id="form1" runat="server">
<div>
</div>

Label1.Text = “Hello World; the time is now “ & DateTime.Now.ToString()


<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>

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



The problem is with label1.text
 
Old December 7th, 2011, 02:41 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,

There are quite a lot of things wrong with this code.

First of all, it has two nested web forms (<form>) which does not work.

Secondly, there's an incomplete label (i.e. it starts with <label but is never finished)

Thirdly, there is code on the page that is just plain text (i.e. Label1.Text should be in the code behind, but right now it's just there as plain markup)

Next, Your "code" uses the VB.NET ampersand (&) character, while your page is using C#. That's not a problem now, but it will be once you move this code to the Code Behind.

Finally, I don't see any Code behind file which is what the exercise is all about. When you double-click the page in Step 5 of the exercise, VWD should open the page's Code Behind for you so you can add the code (the page should have an .aspx.cs extension).

So, all in all, it does't look like the exercise went well. ;- ) Could you try again by following the instructions on page 49 and further to the letter (are you reading the eBook version? You mention page 90, but in the printed copy of the book, this code is on page 49).

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 December 12th, 2011, 03:36 AM
Registered User
 
Join Date: Dec 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Imar,

You were right (obviously) and I was doing something wrong. I read again the part which I got stuck in and managed to fix some issues. Here is the code of the aspx and following the cs

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Demos_Default" %>

<!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:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>

</form>

</body>
</html>


And here is the code of the .cs

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_Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "hello World; the time is now " + DateTime.Now.ToString();
}
}

The error that I am getting is that the name label1 does not exist in the current context. Can you please help?
 
Old December 12th, 2011, 05:15 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hmmm, odd. This code looks exactly as it should. Just copied it into my site and it runs fine.

Where exactly do you get this error? Could it be from another page in your site? And is the casing of the error (i.e. label1 with a lower case l) correct? Your markup and code behind uses an upper case L.

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!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to query dates after 90 days old melkin SQL Language 9 October 30th, 2007 08:03 AM
Rotate a report by 90 degrees csecharith Beginning VB 6 1 January 15th, 2007 02:20 PM
Chapter 2 {curly bracket} parse error of DEATH psychot BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 August 5th, 2005 03:36 PM
Where are Curly Braces required? ababb BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 2 January 20th, 2005 11:47 AM
rotate text 90 degrees lcsgeek Classic ASP Databases 2 September 15th, 2003 10:39 AM





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