Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| 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 September 26th, 2012, 11:15 AM
Registered User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default DateTime code

Hi all

I am reading the following BOOK: Beginning ASP.NET 3.5 : in C# and VB chapter 1 and I hope that you can help me please with this code
<div>
<h1>Hello World</h1>
<p>Welcome to Beginning ASP.NET 3.5 on <% = DateTime.Now.toString %> </p>
</div>

As far as I understood it
this a heading 1 with the <h1> </h1> tag
the paragraph indicated by <p> </p> tag
the <% = DateTime.Now.toString %> the word now used to insert the current date and time but why do we need to put toString ??
have I missed something with my code on line //3 can anybody explain please as I am now to this.

With many thanks
Kind regards
Zulu2012
Reply With Quote
  #2 (permalink)  
Old September 26th, 2012, 11:33 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,084
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Quote:
have I missed something with my code on line //3 can anybody explain please as I am now to this.
Hard to say without more information. Is it not working? If it isn't, do you get an error? Which language do you use? VB or C#? C# is case sensitive and requires parentheses, so you would need to write ToString() instead of toString.

Quote:
but why do we need to put toString ??
<%= %> is a shortcut for Response.Write. The Write method accepts a string only. DateTime.Now on the other hand is a DateTime which is not directly compatible with a string. By calling ToString on the DateTime you can retrieve its string representation.

In this case, it would also work without the call to ToString. However, as you'll see in later chapters, this conversion is required in other places.

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 September 26th, 2012, 11:58 AM
Registered User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reply dateTime code

Reply hello again
Thank you very much for your reply I think that I am using C# in VWD and from what I can say that the date and time is a number and string is a text yes I missed the two closing brackets () after the ToString but I am sorry to say that I still have some errors I copied them below, can you please advise of what is my mistake with many thanks for all your help. With kind regards Zulu2012
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Only Content controls are allowed directly in a content page that contains Content controls.

Source Error:

Line 17: </asp:Content>
Line 18:
Line 19: <div>
Line 20: <h1>Hello World</h1>
Line 21: <p>Welcome to Beginning ASP.NET 3.5 on <% = DateTime.Now.ToString(); %> </p>

Source File: /WebSite2/Default.aspx Line: 19
________________________________________
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
Reply With Quote
  #4 (permalink)  
Old September 26th, 2012, 12:19 PM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,084
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

A few things. First, as the error message suggest, you seem to have your content outside the <content> control which is not allowed:

Code:
 
Line 17: </asp:Content>
Line 18:
Line 19: <div>
Line 20: <h1>Hello World</h1>
Line 21: <p>Welcome to Beginning ASP.NET 3.5 on <% = DateTime.Now.ToString(); %> </p>
Secondly, you can't have a semi-colon after ToString; it's not a statement; it's a value you're sending to Response.Write.

Thirdly, take a look at the source code that comes with the book (downloadable from this website) so you can compare your code with mine.

Finally, you said you have the 3.5 version of the book, but you posted in the 4.0 forum. To avoid future confusion, please post new questions in the appropriate forum at: http://p2p.wrox.com/book-beginning-a...0-18759-3-389/

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
  #5 (permalink)  
Old September 27th, 2012, 12:51 PM
Registered User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default DateTime code

Dear Imar
Thank you very much for your reply, I am sorry to post my question in the wrong form yes I am reading your book Beginning ASP.NET 3.5: In C# and VB kindle edition because I am short sighted and I am struggling to see your code in the book I tried the downloadable code to compare your code with mine but I can start viewing the code from chapter 2 as there is no code for chapter 1, would you advise me to leave my book and start reading your new book Beginning ASP.NET 4: In C# and VB or is the 3.5 version still ok as my visual studio is version 4,
With many thanks
Zulu2012
Reply With Quote
  #6 (permalink)  
Old September 28th, 2012, 09:39 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,084
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Ah, yes, you're right. There is no code for Chapter 1. Sorry about that.

You could use the 3.5 version with VS 2010, but you'll run into some troubles with the ASP.NET controls such as Menu as they render differently in .NET 4. As such, the CSS that comes with the 3.5 book doesn't work correctly with the 4.0 version. You could downgrade your site to ASP.NET 3.5 (on the Property Pages for the site) or you could use the 4.0 code that you can download from this site.

Alternatively, you could wait for my ASP.NET 4.5 book to be released (real soon) and install a copy of the free Visual Studio Express 2012 for Web that the book uses.

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 October 1st, 2012, 11:29 AM
Registered User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reply dateTime code

Dear Imar
Thank you for your reply, I am glad that you informed me that there is no code for chapter 1, I understand what you mean, so I can download the code for ASP.NET 4.0 and still uses the ASP.NET 3.5 book but use the downloaded code for your ASP.NET 4.0 book to go with it. I am running visual studio express 2010 version 4.5 and I am happy to wait for your new book release ASP.NET 4.5 I will be grateful if you can advise what date that your new book will be available so I will buy a copy and download the code with visual Studio 2012.
Thank you I am looking forward to hear from you and looking forward to get your new ASP.NET 4.5 book.

Kind regards
Zulu2012
Reply With Quote
  #8 (permalink)  
Old October 1st, 2012, 11:42 AM
Imar's Avatar
Wrox Author
Points: 72,045, Level: 100
Points: 72,045, Level: 100 Points: 72,045, Level: 100 Points: 72,045, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,084
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

It goes to the printer tomorrow ;-) Amazon.com says it's available on November 6th.

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
  #9 (permalink)  
Old October 1st, 2012, 11:46 AM
Authorized User
Points: 257, Level: 5
Points: 257, Level: 5 Points: 257, Level: 5 Points: 257, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Location: Healing, UK
Posts: 59
Thanks: 2
Thanked 4 Times in 4 Posts
Default

Well done Imar and Good Luck on the New Book.

Ian
Reply With Quote
  #10 (permalink)  
Old October 3rd, 2012, 10:28 AM
Registered User
Points: 30, Level: 1
Points: 30, Level: 1 Points: 30, Level: 1 Points: 30, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default new book

Dear Imar
Thank you for your reply and well done with your new book, yes I have check on amazon uk and the paperback version will be available on 9 Nov, however I prefer to buy the kindle format can you please advise if I will be able to get the book in kindle format or PDF format?.

In the mean time I downloaded the code for book 4 and I will carry on reading my 3.5 book and using your code for book 4. Is that ok?
Thank you
Kind regards
Zulu2012
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
CH5 - Code for DateTime Tester Application? alwayssummer BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 4 December 16th, 2010 12:11 PM
3 days prior datetime from current datetime bsridharg XSLT 2 June 11th, 2010 11:26 PM
How do I compare a datetime to current datetime and find the one closest to it? Anders XSLT 17 March 15th, 2010 10:28 AM
DateTime RickP SQL Server 2000 7 December 14th, 2005 07:08 PM
UTC DateTime to Local DateTime r_ganesh76 SQL Server 2000 1 April 4th, 2005 08:21 AM



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


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