SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Label and background image in css file

    hi there, I hope your help.

    I need in my aspx page replace this layout:
    immagine1.jpg
    to change new layout with inserting new values of my code behind:
    Code:
                Label1.Text = Convert.ToString(dr["myDates"]);
                TITLE = Convert.ToString(dr["TITLE"]);
    But I have this output wrong because the image is canceled and the value of date is left and not supported in the initial image:
    immagine2.jpg
    css file:
    Code:
    .templatemo_product
    {
        float: left;
        width: 455px;
        height: 105px;
        padding: 10px;
        background: url(images/templatemo_products.jpg) no-repeat;
        display:block
    }
    aspx file:
    Code:
                <div class="templatemo_product">
                    <asp:Label ID="Label1" runat="server">
                    <img src="images/templatemo_photo1.jpg" alt="templatemo.com"
                        width="117" height="76" />
                    <strong>Vivamus a massa</strong><br />
                    Donec iaculis felis id neque. Morbi nunc. Praesent varius egestas velit. Donec a
                    massa ut pede pulvinar vulputate. Nulla et augue. Sed eu nunc quis pede tristique
                    suscipit. Nam sit amet justo vel libero tincidunt dignissim. 
                    </asp:Label>
                    <a href="#"><strong>READ MORE </strong></a>
                </div>
    code-behind:
    Code:
                Label1.Text = Convert.ToString(dr["myDates"]);
                TITLE = Convert.ToString(dr["TITLE"]);
    Can you help me?
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye

  2. #2
    SitePoint Zealot imouto's Avatar
    Join Date
    Sep 2004
    Location
    Gotham
    Posts
    184
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Could you provide a link to your page so people can see what HTML code is being rendered and therefore what the issue looks like?

    Also, I could be wrong about this since I haven't touched an ASP.Net site in ages, but shouldn't that closing label control tag go right after the opening tag? Like so:

    Code:
    <asp:Label ID="Label1" runat="server"></asp:Label>
    You could also just write it like this as a self-closing tag:
    Code:
    <asp:Label ID="Label1" runat="server" />
    And for what you're using the label control for, it might make more sense to use a LITERAL control instead of a label control. Check out this old blog entry that does a good job of explaining the difference between the two - http://haacked.com/archive/2007/02/1...correctly.aspx

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,827
    Mentioned
    142 Post(s)
    Tagged
    0 Thread(s)
    As @imouto ; started to hint on your label tag contains TOO much, so when you assign the .Text property, you are overwriting what is already contained in the label.

    Code:
                    <asp:Label ID="Label1" runat="server">
                    <img src="images/templatemo_photo1.jpg" alt="templatemo.com"
                        width="117" height="76" />
                    <strong>Vivamus a massa</strong><br />
                    Donec iaculis felis id neque. Morbi nunc. Praesent varius egestas velit. Donec a
                    massa ut pede pulvinar vulputate. Nulla et augue. Sed eu nunc quis pede tristique
                    suscipit. Nam sit amet justo vel libero tincidunt dignissim. 
                    </asp:Label>
    Write the label so it includes ONLY want you want to overwrite, or use a self-closing tag so you can inject new text into your existing content.
    Be sure to congratulate xMog on earning April's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  4. #4
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    thank you.
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye


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
  •