Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 31st, 2008, 04:59 PM
Authorized User
 
Join Date: Jan 2007
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default I am back

Hi Imar,

This is my second book authored by you (11th book by Wrox). I was so impressed with the help you provided in a previous forum that I decided to continue to buy your books when related to my needs. So I bought this one (received my order today with a few other books from Wrox).

I just wanted to say hi and that I'm looking forward to moving into this book.
 
Old April 1st, 2008, 11:59 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi to you too..... Hope you like the book.

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.
 
Old April 1st, 2008, 08:43 PM
Authorized User
 
Join Date: Jan 2007
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just started Chapter 4 and am loving the book (or enjoying it). After reading Chapter 3 (css) and starting Chapter 4 (controls), a question came to mind that I can't seem to find an answer for. Perhaps you could shed some light on it (or tell me to keep reading if your book does shed some light on it later):

    <style type="text/css">
        .textBoxBorder
        {
            border-color: #CC0066;
        }
        #TextBox3
        {
            border-color: #CC0066;
        }
    </style>

        <asp:TextBox ID="TextBox1" runat="server" BorderColor="#CC0066"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" CssClass="textBoxBorder"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

All three TextBoxes have the same effect, having a border colour #CC0066; (colour - from canada aye)

TextBox1 doesn't seperate data from presentation so the solution is to add a CssClass as in TextBox2. (I never seen CssClass before. Is that a serverside code for .class?)

However, could I not use the sample in TextBox3, reusing the ID="Textbox3" by adding #Textbox3 in the CSS file? I am aware that the ID in this case is used for other things, but will that cause a conflict?

 
Old April 2nd, 2008, 12:28 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, you could reuse TextBox3. However, since an ID has to be unique across the page, you can't really reuse it. Besides, due to page hierarchy with Master Pages and User Controls, your text box may end up with a different client ID in the browser, breaking the CSS.

I typically use ID for elements that appear once in a page, like #MainMenu and #Content and use classes for elements that can be repeated like a .TextBox.

And yes, CssClass in ASP.NET maps to a class attribute in HTML:

<asp:TextBox CssClass="SomeClass ..../>

becomes:

<input type="text" class="SomeClass" ..../>

Hope this helps,

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.
 
Old April 2nd, 2008, 12:54 AM
Authorized User
 
Join Date: Jan 2007
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default

By reusing, I meant by using the id="TestBox... only in the css file. I would only do this if I only wanted to make a change to that textbox alone. I could do the same with the CssClass but it seems like overkill. I guess I better stick with the rules and use the CssClass... hehehe

Thanks

 
Old April 2nd, 2008, 03:47 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Not sure what you mean with this:
Quote:
quote:I meant by using the id="TestBox... only in the css file. I would only do this if I only wanted to make a change to that textbox alone.
Can you explain this in a bit more detail?

#TextBox3 can *only* be used by controls called TextBox3. As you'll see in later chapters, it's not always easy to rely on this ID staying the same...

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.
 
Old April 2nd, 2008, 08:36 AM
Authorized User
 
Join Date: Jan 2007
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

If TextBox3 is used in the Default.aspx.vb page, and I use the same id to format the textbox in the css file, then it's used again (REUSED). I may want to format the table using css, and this table alone (style). If so, why can't I just use #TextBox3 { ... } in the css file? I know about CssClass, which is great if you want to use the style on other pages, etc.

It's no big deal really as I can use CssClass even if it's just for one textbox, it's just more typing and takes up extra space. It's silly because it's not a whole lot of typing and it doesn't use a whole lot of extra space.

 
Old April 2nd, 2008, 08:46 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

As Imar suggests, when you begin working with Master Pages the controls on your content page will normally wind up with an ID other then how you may access it in your code behind.

For example, I quickly created a Master Page and content page. On my content page I placed a textbox control and named it txtFoo. When I viewed the website in my browser and viewed the source of the page, the name of my textbox had been changed to:

ctl00_ContentPlaceHolder1_txtFoo

Again, as Imar said, this would break my css if i had defined a style for #txtFoo.

Does this answer your question?

================================================== =========
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
================================================== =========
 
Old April 2nd, 2008, 08:59 AM
Authorized User
 
Join Date: Jan 2007
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Oh... thank you for pointing that out. It worked fine on a sample I had without a master page, but I looked at a sample with a master page. It did change the ID. Well the settles it then. Thanks again for pointing that out.

 
Old April 2nd, 2008, 09:25 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No problem, glad that cleared it up for you. =]

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Going back ... possible? asearle XSLT 2 January 8th, 2007 06:24 AM
I'm back mehdi62b C# 10 August 14th, 2006 04:53 PM
Back Up tsimsha Classic ASP Databases 0 September 19th, 2004 08:42 PM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM
Back Up shamsad Oracle 0 February 11th, 2004 06:00 AM





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