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 April 17th, 2008, 10:46 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 4: Page 391 - ButtonType

Hi Imar,

You mentioned said could generate a button using the following code:

<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
            ShowSelectButton="True" ButtonType="Button"> </asp:CommandField>


I've noticed that others have used the code below. It seems easier to use. Could the code below create a problem?

<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
            ShowSelectButton="True" ButtonType="Button" />

Thank you,
Terry



Reply With Quote
  #2 (permalink)  
Old April 17th, 2008, 11:07 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 only difference between the two examples that you have presented is that the latter is a self closing tag (hence the /> at the end instead of </asp:CommandField>). Either example will work fine without a problem.

On thing to keep in mind is that you can use this short hand to close all of your Server Control tags (Label, button, textbox, etc) however, you can't use this short hand on a dropdownlist, for example, when you explictly define the items displayed in the list:

<asp:DropDownList ID="drp" runat="server">
<asp:ListItem>foo</asp:ListItem>
</asp:DropDownList>

hth.

-Doug



================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
  #3 (permalink)  
Old April 17th, 2008, 11:26 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

Or:

<asp:DropDownList ID="drp" runat="server">
  <asp:ListItem Text="foo" Value="foo" />
</asp:DropDownList>

;)

But Doug is right; there's no difference. I usually use /> but sometimes I forget an element is self closing and accidentally type >. Then VWD inserts the end tag automatically which I usually leave in there.

Feel free to choose whatever you are most comfortable with.

Also, check out Tool | Options | Text Editor | HTML | Format.

Then click the Tag Specific Options button. In the dialog that follows, you can control the way tags are entered in the designer, including whether they auto close or not.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #4 (permalink)  
Old April 17th, 2008, 11:45 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's great, thanks guys...

Terry

Reply With Quote
  #5 (permalink)  
Old April 17th, 2008, 11:45 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

<asp:ListItem Text="foo" Value="foo" />

Yep that will work to! ;]

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor / Author :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
  #6 (permalink)  
Old April 19th, 2008, 05:12 AM
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Imar
 Or:

<asp:DropDownList ID="drp" runat="server">
<asp:ListItem Text="foo" Value="foo" />
</asp:DropDownList> ...
Oh, sort of like the code automatically generated on page 400:

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
        DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id"
        AppendDataBoundItems="True">
        <asp:ListItem Value="">Please make a selection</asp:ListItem>
    </asp:DropDownList>

Which can be changed to:

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
        DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Id"
        AppendDataBoundItems="True">
        <asp:ListItem Value="" Text="Please make a selection" />
    </asp:DropDownList>

If it's a better code, why isn't the program creating it that way?

Terry

Reply With Quote
  #7 (permalink)  
Old April 19th, 2008, 06:57 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

Who says it's better code? I just posted my code example to show another variation of self closed elements.

Both come down to the same thing; there is no difference at run-time so again you can choose whatever you see fit or like best.

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #8 (permalink)  
Old April 19th, 2008, 08:42 PM
Authorized User
 
Join Date: Jan 2007
Location: , , .
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:Originally posted by Imar
 Who says it's better code? I just posted my code example to show another variation of self closed elements.

Both come down to the same thing; there is no difference at run-time so again you can choose whatever you see fit or like best.

Imar
I'm saying it's a better code as it takes less bites. Yes they both work.

ALSO: I didn't even mention your code as I wasn't even thinking of your code. I said "... like the code automatically generated on page 400." I did the exercise on page 400 and the code was generated for me automatically.

My message was meant to show you that I not only understood you, but agreed with you. I was just delighted that I learned something (and learned a lot more than I shared here just because of the post I was referring to).

I apologize if I didn't word my post correctly. But be delighted that I learned something due to your original post that I was referring too, showing you that the forum is very helpful.

Thank you for it...

Terry
Reply With Quote
  #9 (permalink)  
Old April 20th, 2008, 04:35 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

Right I see.

Fortunately, VWD gives you full control over this so you can code it any way you want..... ;)

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
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
Chapter 9 Page 304 AspNetGuy BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 12 December 22nd, 2009 11:17 AM
Problem with Chapter 2 First Page xtiano77 ASP.NET 3.5 Basics 1 May 7th, 2008 01:00 AM
Chapter 3 - Page.IsCrossPagePostBack dpereira BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 9 October 25th, 2006 07:50 AM



All times are GMT -4. The time now is 07:59 PM.


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