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

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

December 7th, 2011, 03:56 AM
|
 |
Wrox Author
Points: 72,055, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
|
|
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
|

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

December 7th, 2011, 02:41 PM
|
 |
Wrox Author
Points: 72,055, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
|
|
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
|

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

December 12th, 2011, 05:15 AM
|
 |
Wrox Author
Points: 72,055, Level: 100 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
|
|
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
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |
All times are GMT -4. The time now is 02:48 PM.
|