p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning ASP.NET 4 : in C# and VB (http://p2p.wrox.com/forumdisplay.php?f=560)
-   -   Lot's of Questions (http://p2p.wrox.com/showthread.php?t=93434)

Jhalad August 21st, 2014 11:31 AM

Lot's of Questions
 
I have a lot of questions in regards to the book content. I don't just want to type the code and regurgitate what I read. I want to understand why I'm typing what I'm typing. That said...

1. On page 7, step 7, I put % in the line to display the date/time. Why? If I delete them, the code still appears to work. On page 50, virtually the same code is used, but the % isn't there. Why?

2. On page 14, at the bottom, I am told most ASP.NET tags begin with asp: prefix. Why? What purpose does the "asp" serve and is it always necessary?

3. I frequently see runat="server" inserted into the code. Does this mean that the code runs on the server, like suggested on page 15, second paragraph? Can I delete it, or put something else in? What else can I put in?

4. On page 164, step 4, the number entered on the calculator is converted to a Double. I'm guessing this is to allow for extremely large numbers AND to allow for slightly faster computation?

I'm sure I'll come up with more. I am not just looking for answers. If someone can direct me to a place where I can find them, COOL! I just like learning exactly WHAT I'm typing and not just relying on the VWD GUI to do everything for me or just regurgitate some code because "that's what I was taught".

Thanks for the help!
Regards,
William

Imar August 21st, 2014 11:44 AM

Hi there,

Quote:

1. On page 7, step 7, I put % in the line to display the date/time. Why? If I delete them, the code still appears to work. On page 50, virtually the same code is used, but the % isn't there. Why?
The % symbol makes it code that runs at the server. If you remove it, the code stops working. <%= => is a shortcut for Response.Write; e.g. it write to the final HTML directly where it's used. The code on page 50 is defined in the code behind and runs at the server. It's in code, not in markup and thus doesn't write to the response directly, but assigns the value to some other control.

Quote:

2. On page 14, at the bottom, I am told most ASP.NET tags begin with asp: prefix. Why? What purpose does the "asp" serve and is it always necessary?
ASP.NET needs some way to identify arbitrary code and notice these are server controls that need to be processed. The Microsoft team chose asp for obvious reasons (since the framework is called ASP.NET). For your own controls you pick almost anything.

Quote:

3. I frequently see runat="server" inserted into the code. Does this mean that the code runs on the server, like suggested on page 15, second paragraph? Can I delete it, or put something else in? What else can I put in?
Runat="server" is the only available option. It makes the control run at the server and is required to operate.
Quote:

4. On page 164, step 4, the number entered on the calculator is converted to a Double. I'm guessing this is to allow for extremely large numbers AND to allow for slightly faster computation?
And to support fractional numbers.

Cheers,

Imar

Jhalad August 21st, 2014 03:06 PM

Thanks!

Another noob question.

Comments. I know that in VB they need to be preceded by a tick mark '. I've tried to insert comments in Markup, but they come out IN the screen. I did notice that I can put them in the "Code Behind" page, and the text turns green and doesn't interfere with the program. Is this normal, or am I doing something wrong in the Markup page?

Never mind. Figured it out. <%-- Comment --%>

The tick mark is for Code Behind only.

Imar August 21st, 2014 04:05 PM

Yep, correct. You can find more about comments here: http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx

Cheers,

Imar

Jhalad August 22nd, 2014 11:51 AM

Next question. Well, verification, actually
 
I'm going through Chapter 5, and as recommended, typing the code into a "Test Page". When I type of three VB.NET codes at the bottom of page 150 (making new Lists), the Button one turns light blue vs. dark blue. I'm guessing this is because Button is a control, like List is?

Imar August 24th, 2014 07:01 AM

Hi there,
Quote:

I'm guessing this is because Button is a control, like List is?
No, that's not it. int and bool turn dark blue because they are C# types; shortcuts for types in .NET. If you were to change int to Int32 (the corresponding .NET type) and bool to Boolean, they would turn light-blue as well.

BTW: List is not a control. It's a type that can be used anywhere in any .NET application and can hold objects of a specific type.

Hope this helps,

Imar


All times are GMT -4. The time now is 04:22 AM.

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