Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 March 23rd, 2006, 02:44 PM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default asp:Label control - 2 problems

I've searched all 19 forum pages for the answer to 2 super simple problems but to no avail. Gotta be easy answers but have not found them in 2 days of trying:

Situation: A simple webpage not employing a css sheet from a master page with no css.

Problem 1. The page contains 2 image buttons spanning most of the content area. I want 2 label controls, centered above the buttons.

Code below works and looks good in design view, but when I run it, the left label has moved to the left margin. Righthand label stays put.

Problem 2. The labels' text properties are strings with 4 blanks between words. At both design and run time the 4 embedded blanks have been changed to 1 blank.

    <asp:Label style="position: absolute; margin-left: 10; left: 160px" ID="Label3" Width="160px" runat="server"
Text="Complete Burrow System"></asp:Label>

    <asp:Label style="position: absolute; margin-right: 10; right: 160px" ID="Label4" Width="160px" runat="server"
Text="Complete Treetop System"></asp:Label>

I could probably put a table with one row and two columns and center the text in the cells, but that seems like a lot to go thru to solve a simple problem with labels.

Can anyone help me out with these? Thanks.

VictorVictor





Reply With Quote
  #2 (permalink)  
Old March 23rd, 2006, 02:59 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

1. Use a table or CSS to postion the controls. Design view and runtime view will differ once the page is actually rendered.

2. Nothing you can do, I have had this problem in the past. For some reason the extra white space is removed in a label's text.

Jim

Reply With Quote
  #3 (permalink)  
Old March 23rd, 2006, 03:53 PM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Jim:

Thanks for your quick reply.

It's pretty discouraging (unbelievable really) that MS could come out with a product that a brand new user like me with my very first app using VWD Express, runs into such an obvious flaw on a control used everywhere by everyone. Right off the bat! Wow!

How could this possibly escape fixing when there were 2 betas, a community product, and armies of testers?

I wonder what other time wasters I'll thrash around for days on?

I was planning on buying a version of VS 2005, now I'll delay until they come out with a fix. Thanks again.

VV


Reply With Quote
  #4 (permalink)  
Old March 23rd, 2006, 04:16 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Don't expect a fix. The way the page renders is the way it is, that's why you need CSS or tables. As for the label thing, there is probably a reason for it, if you can possibly dig and find it. Don't think it's worth the effort.

VS2005 is awesome.. been using it for a while now... you should look into it.

Reply With Quote
  #5 (permalink)  
Old March 23rd, 2006, 04:52 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

The reason for the disappearing spaces is by design. Not in VWD, but in HTML.

Multiple consecutive spaces (and other white space) are ignored. This is not something Microsoft did, but something that the (X)HTML standard dictates.

Use &nbsp; (non breaking space) if you want to force a space. So, &nbsp;&nbsp;&nbsp; would result in three spaces.

IMO, it makes sense that ASP.NET removes the spaces from the final output, as they wouldn't have an effect anyway.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #6 (permalink)  
Old March 23rd, 2006, 05:07 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Thanks for the explination Imar.. I figured it had something to do with rendering...

Jim

Reply With Quote
  #7 (permalink)  
Old March 23rd, 2006, 05:16 PM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Jim and Imar:

Thanks for the help.

Yes, I went ahead and used a 1 row table and problem solved.

It is very nice to know that MS is not the culprit on this thing.
Restores my faith in MS. (Been a VB user since VB came out, but did
not write web stuff.)

After wearing myself out, decided to read the book (Yup, book last).
But searching Wrox's Beginners and Professional ASP.NET 2 books gave
no clue about the odd behavior. Also searched Wrox's CSS for Web Design
book still got no clue.
Whatever, onward and upward. I'm sure they're be other issues that come up
and thank God guys like y'all are willing to help.

VV



Reply With Quote
  #8 (permalink)  
Old March 23rd, 2006, 05:47 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Glad to help.. Good luck.. :)

Reply With Quote
  #9 (permalink)  
Old April 14th, 2006, 10:14 AM
Friend of Wrox
 
Join Date: Apr 2005
Location: Fort Walton Beach, FL, USA.
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Good news (for a change).
I have solved the problem of exactly positioning on a page, text whereever I want.

I think JBensen or Ivan S. mentioned a css (Cascading Style Sheet) earlier.

I have bought Richard York's Wrox book Beginning CSS for Web Design and Rich
has some explanation on the white-space property (page 199). The use of this property,
specifying 'pre' preserves white space in text. Not only does it preserve the many spaces, it preserves the carriage return/line feeds.

Below is a snippet of code from an .aspx page, and below that a snippet from an associated .css document.

If you have had the problem of trying to preserve embedded blanks in text and been unable to, this is the technique:


----------------web page-------------------
    <div class="pre">
                        Line 1
                        Line 2 para 3 para 4 para 5
                        para 6 para 7
                        para 8 para 9 para 10 para 11
    </div>




----------------css doc--------------------
.pre{white-space:pre;}



VictorVictor



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
Binding SQLDataSource To A Label Control sg225551 ASP.NET 2.0 Basics 1 January 16th, 2008 10:36 AM
How To Display ToolTip for label control maulik33 ASP.NET 2.0 Basics 1 August 27th, 2007 08:42 AM
A question about Label Control of VS.net2003 roki_chen General .NET 0 July 5th, 2006 10:17 PM
W3C XHTML Validation on ASP:Label control rit01 ASP.NET 2.0 Basics 6 June 26th, 2006 12:30 PM
Chart Wizard - Label Problems socoolbrewster Access 1 April 18th, 2005 11:32 AM



All times are GMT -4. The time now is 09:24 AM.


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