SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    San Francisco, CA
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to get rid of whitespace that dotNet inserts

    I have a problem where this code

    Code:
    <asp:Panel ID="photo" runat="server"><asp:Image ID="mainphoto" runat="server" width="549" /></asp:Panel>
    outputs this HTML

    Code:
    <div id="ClubhouseMainPhoto_photo" class="people photoMain">
    <img id="ClubhouseMainPhoto_mainphoto" src="/root_images/bigphotos/outings.jpg" style="width:549px;border-width:0px;" />
    </div>
    The line returns is causing a little extra line to appear below the image, which I would like to get rid of (In IE6 at least. It is fine in Firefox). Any way to force the controls to NOT insert the line breaks/whitespace?

    in other words if I change the HTML to output the following, it displays perfectly fine:
    Code:
    <div id="ClubhouseMainPhoto_photo" class="people photoMain"><img id="ClubhouseMainPhoto_mainphoto" src="/root_images/bigphotos/outings.jpg" style="width:549px;border-width:0px;" /></div>
    Thanks

    P.S. the CSS involved is this:

    Code:
    .photoMain{
        border: 0px solid white;
        border-top: 1px solid white !important;
        border-left: 1px solid white !important;
        padding-top: 10px;
        padding-left: 10px;
    }
    .people { background-color: #669900; }

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,875
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Use one of the following stylesheet commands to fix it:

    #ClubhouseMainPhoto_mainphoto {display:block;}

    #ClubhouseMainPhoto_photo {line-height:0;}
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I would just ditch the panel--it serves no purpose that I can see here.

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    San Francisco, CA
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Felgall, that fixed it. Thanks!

    Thanks wwb_99, I would not have the panel in there if it did not serve a purpose.

    But even if was useless its still a perfectly valid question, the forum instructions do say to just put in the necessary code, do they not?

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Let me rephrase the question: does the panel do anything that a PlaceHolder could not do? Or, do you actually need the Panel to output anything or rather act as a container for dynamically created controls?

  6. #6
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    San Francisco, CA
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, wwb_99, that is a more useful question. I actually didn't know about the placeholder.

    however, i do need the panel's DIV for visual reasons... to work out the design I've been handed.

    the vbscript is setting a dynamic class on the panel. I wouldn't be able to do all i need to do setting it on the IMG alone.

  7. #7
    SitePoint Wizard
    Join Date
    Feb 2007
    Posts
    1,274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, instead of a Panel you may be able to get by with "just" a server side div tag.

  8. #8
    SitePoint Member xela220's Avatar
    Join Date
    Oct 2005
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I always have this problem. I think that is a bug or something.

    Instead of doing this:

    <div id="ClubhouseMainPhoto_photo" class="people photoMain">
    <img id="ClubhouseMainPhoto_mainphoto" src="/root_images/bigphotos/outings.jpg" style="width:549px;border-width:0px;" />
    </div>


    Try this:

    <div id="ClubhouseMainPhoto_photo" class="people photoMain"><img id="ClubhouseMainPhoto_mainphoto" src="/root_images/bigphotos/outings.jpg" style="width:549px;border-width:0px;" />
    </div>


    Don't leave any spaces between the div and img tag. That usually works for me. Same deal if it is the first tag in a cell.

    If that doesn't work try using a <pre> tag.

    And if that doesn't work get rid of the div tag by doing this:
    <img id="ClubhouseMainPhoto_mainphoto" src="/root_images/bigphotos/outings.jpg" style="width:549px;border-width:0px;" class="people photoMain"/>


    Hope this helps.

  9. #9
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    San Francisco, CA
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    honeymonster,

    didn't see your reply until just now -- can you set a cssclass on an htmlcontrol. doesn't seem to work, but perhaps you have to reference the tag in a particular way?

    hey xela220,

    unfortunately no, I know that would work if I was putting in the HTML myself. But as I described in my original message, the problem is how ASP.NET outputs the HTML from web controls.

    felgall's CSS solution however was one that worked.

  10. #10
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    With a server-side div, you can add a class, or you can specify one in the ASxX template:

    Code:
    <div id="SomeServerSideDiv" class="CssClass" />
    Code:
    SomeServerSideDiv.Attributes["class"]="CssClass";

  11. #11
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Location
    San Francisco, CA
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks wwb_99,
    I assume it has to have a runat in it? in order to set it in the ASxX
    Code:
    <div id="SomeServerSideDiv" class="CssClass" runat="Server" />

  12. #12
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,653
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Yes, you are correct.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •