Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 December 30th, 2008, 11:09 PM
Friend of Wrox
Points: 505, Level: 8
Points: 505, Level: 8 Points: 505, Level: 8 Points: 505, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2008
Location: , , .
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
Default recommend book for C# language?

Hi Imar:

I'm trying to understand what some of this language means such as :

<%= ... %>
<%$ .... %>
<%# ... %>

Is there a book for beginners that teaches all these symbols? I am typing all the exercises but I really don't know what I'm saying and I think it would help me understand what I'm doing (& better what ASP.NET was doing) if I understood what these terms mean.

'<%# Eval("someword") %>' is used a lot in the book. All I know is that it means that its evaluating some text .

Now that I'm in chapter 13, I see
'<%# Bind("somethin") %>' a good bit. I know that this means to bind some data to the database but again, its sort of vague to me so I'm not sure I could actually use it if I weren't copying it out of some existing code.

Is there maybe a list like on page 149 where these symbols are defined?


Thanks,

Rachel
Reply With Quote
  #2 (permalink)  
Old December 31st, 2008, 01:35 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The easiest way to explain it is that they are shorthand expressions that reduce the amount of code you have to write.

To answer your question:

<%= %> is the equivalent of Response.Write();
<%$ %> is an expression. And it takes this form: <%$ expressionPrefix: expressionValue %> So, for example, you might do something like this on your web form in a content well (Assume that you have a key in your app settings named Foo):

<%$ AppSettings: Foo %>

This is no different than doing something like Response.Write(ConfigurationManager.AppSettings["Foo"])

Finally the <%# %> is a DataBinding expression and you can use it for either one way (read only) or two way (updateable) binding. You will typically only ever use this expression inside of controls that you can databind data sources to (DropDownList, Repeater, GridView, etc).

The two forms of the databinding expression are:
<%# Eval("ColumnName") %> (Used for one-way readonly binding)
<%# Bind("Column1") %> (Used for two-way updateable binding)

In the case of the latter it is typical that you would see its used in a manner such as:

aspnet Code:
<asp:TextBox ID="textboxColumn1" RunAt="Server"
          Text='<%# Bind("Column1") %>' />

so that any changes to the data could be persisted back to the database whereas the former of the two could simply exist in a div such as:

aspnet Code:
<div>
    <%# Eval("ColumnName") %>
</div>

Does that help clear things up?


In so far as a book that defines all of these symbols, the closest you will come is probably the MSDN because a book containing nothing but defintions of symbols and such would be cumbersome to read (when was the last time you heard of someone randomly reading a dictionary! ;]).

Google is a great resource for getting answers to things like this and I suggest using it.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
Reply With Quote
The Following User Says Thank You to dparsons For This Useful Post:
Rachel (December 31st, 2008)
  #3 (permalink)  
Old December 31st, 2008, 08:39 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Doug,

Excellent explanation except for this:

Quote:
<%$ AppSettings: Foo %>
This is no different than doing something like Response.Write(ConfigurationManager.AppSettings["Foo"])
Although the net effect may appear to be the same, it really isn't. You can use this expression syntax at locations where Response.Write wouldn't make sense. For example, when used to feed a connection string in a SqlDataSource:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PlanetWroxConnectionString1 %>" >

When the page instance is created, this ConnectionString property is fed with the value from PlanetWroxConnectionString1. No Response involved, as nothing is sent to the browser.

I know you know this, but I wanted to set it straight just for the record... ;-)

Cheers and Happy new Year.

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
The Following User Says Thank You to Imar For This Useful Post:
Rachel (December 31st, 2008)
  #4 (permalink)  
Old December 31st, 2008, 10:17 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Thanks for clearing that up Imar. =]

Happy New Year to you too!

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
Reply With Quote
  #5 (permalink)  
Old December 31st, 2008, 03:02 PM
Friend of Wrox
Points: 505, Level: 8
Points: 505, Level: 8 Points: 505, Level: 8 Points: 505, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2008
Location: , , .
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
Default

Thanks. That cleared it up a little.

Rachel
Reply With Quote
  #6 (permalink)  
Old December 31st, 2008, 03:19 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You say that it cleared it up "a little" what questions do you still have or what isn't clear?

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
Reply With Quote
  #7 (permalink)  
Old December 31st, 2008, 06:26 PM
Friend of Wrox
Points: 505, Level: 8
Points: 505, Level: 8 Points: 505, Level: 8 Points: 505, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2008
Location: , , .
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
Default

It's not your explanation, its me.

I just don't know the language well enough for it to make sense really. I just see that you use this for that, etc. You say that:

" <%= %> is the equivalent of Response.Write(); "

But I don't know what "Response.Write(); is.

I'm a beginner at this. I only knew a very little Visual Basic which I learned enough to put together a windows program years ago. Much has changed since that!

Thanks,

Rachel
Reply With Quote
  #8 (permalink)  
Old December 31st, 2008, 06:49 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

>< Sorry, my mistake. I will keep everything fairly basic for you:

Response.Write is used when you want to write SOMETHING out to your page. For example say you have a random page and you want to write out that servers current date for the user, you could put code similar to this in your Page Load event:

csharp Code:
Response.Write(DateTime.Now.ToShortDateString());

This will display the date on the page but, when using Response.Write, you have no control over where the Text is placed (it is typically at the very top of the page) which is less than desirable so you could get away with doing something like this:

html Code:
<div>
    <%=DateTime.Now.ToShortDateString()%>
</div>

This allows you to control where exactly this Date shows up since you can move the div practically anywhere. The one thing to keep in mind is that you can only use <%= %> on public members. So if you are working with some variable in your class file that you want to display to the user it needs to be defined as a class level variable that is defined with the public keyword otherwise you will get an error.

I am not sure how Imar does things in his book but I prefer using the Text property of Labels or literals to display information to the user as opposed to Response.Write or <%= %>.

Does this make more sense? Do you need further elaboration on the other two items?

hth
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
Reply With Quote
  #9 (permalink)  
Old January 1st, 2009, 12:32 PM
Friend of Wrox
Points: 505, Level: 8
Points: 505, Level: 8 Points: 505, Level: 8 Points: 505, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2008
Location: , , .
Posts: 119
Thanks: 26
Thanked 0 Times in 0 Posts
Default

Thanks a lot Doug. Now its even clearer. "Response.Write" sounds like a logical term for what it actually does - 'responds with writing something out' and that helps me understand it better.

Rachel
Reply With Quote
  #10 (permalink)  
Old January 1st, 2009, 12:44 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No problem! ^^

Happy New Year.

-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
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
Can you recommend this book? Hanne B. Stegemueller BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 4 December 7th, 2006 11:13 AM
Can you recommend this book? barberj BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 4 June 5th, 2006 04:38 AM
Recommend a Book... s15199d BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 2 March 3rd, 2006 02:48 PM
Re: recommend a book for new user? flyfish Crystal Reports 0 April 28th, 2005 03:52 PM



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


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