locked
Paragraph with links...? RRS feed

  • Question

  • User2035321518 posted

    OK, this may sound novice, but I'm a creative director with just enough ASP.NET experience to be very dangerous. I'm developing a site for us-EN, ca-EN, and ca-FR.

    Say I had a paragraph with a link, such as:

    <p >
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras accumsan gravida nisi,
            nec convallis nulla condimentum quis. Morbi magna nunc, porttitor at faucibus eget,
            mattis a dolor. Maecenas leo massa, venenatis a adipiscing vitae, ultrices sed ipsum.
            Phasellus placerat pharetra lorem, vel malesuada nisi pharetra ac. Donec eleifend
            tincidunt viverra. Nam mi tortor, tincidunt consequat scelerisque vel, tristique
            et enim. Sed malesuada orci at magna pharetra bibendum. Fusce dignissim, libero
            sed rutrum egestas, orci tortor euismod augue, in blandit nibh nunc id lectus. Duis
            metus odio, porta ut dapibus non, vestibulum ut sem. Quisque varius lacus velit.
            In eget quam et nisl mattis tristique bibendum sed est. <a href="Default.aspx">Maecenas congue tincidunt
            neque, non commodo felis accumsan nec.</a> Phasellus quis sem sapien. Nulla et tincidunt
            ligula. Integer vestibulum libero nec metus accumsan porta ultricies sapien pellentesque.
            Proin vehicula est eget lacus euismod varius. Ut quis neque urna, at porttitor nunc.
            Praesent nec metus eu risus congue facilisis non vel lectus. Nam fermentum justo
            non lorem rutrum a rutrum mi mattis. Aliquam sollicitudin tellus ac arcu posuere
            in egestas augue elementum.
        </p>

    Everything I've read says to put this into a label. I'm just not sure what the best practice is of handling this for the resource files. I would love to keep the entire paragraph together so it doesn't end up looking like this:

    <asp:Label ID="Label1" runat="server" Text="Lorem ipsum dolor sit amet,
            consectetur adipiscing elit. Cras accumsan gravida nisi,
            nec convallis nulla condimentum quis. Morbi magna nunc, porttitor at faucibus eget,
            mattis a dolor. Maecenas leo massa, venenatis a adipiscing vitae, ultrices sed ipsum.
            Phasellus placerat pharetra lorem, vel malesuada nisi pharetra ac. Donec eleifend
            tincidunt viverra. Nam mi tortor, tincidunt consequat scelerisque vel, tristique
            et enim. Sed malesuada orci at magna pharetra bibendum. Fusce dignissim, libero
            sed rutrum egestas, orci tortor euismod augue, in blandit nibh nunc id lectus. Duis
            metus odio, porta ut dapibus non, vestibulum ut sem. Quisque varius lacus velit.
            In eget quam et nisl mattis tristique bibendum sed est."></asp:Label><asp:HyperLink
                ID="HyperLink1" runat="server" NavigateUrl="~/Default.aspx">Maecenas congue tincidunt
            neque, non commodo felis accumsan nec.</asp:HyperLink><asp:Label ID="Label2" runat="server"
                Text="Phasellus quis sem sapien. Nulla et tincidunt
            ligula. Integer vestibulum libero nec metus accumsan porta ultricies sapien pellentesque.
            Proin vehicula est eget lacus euismod varius. Ut quis neque urna, at porttitor nunc.
            Praesent nec metus eu risus congue facilisis non vel lectus. Nam fermentum justo
            non lorem rutrum a rutrum mi mattis. Aliquam sollicitudin tellus ac arcu posuere
            in egestas augue elementum."></asp:Label>

    This gets a bit ridiculous in my mind. Any help or guidance would be appreciated. I can't find any answer to this.

    Thanks in advance!

     

     

    Friday, April 29, 2011 2:15 PM

Answers

  • User2130758966 posted

    For simple values you can just put the value in the Text property, for complex values such as including hyperlinks you put it between the open and close tags:

    <!-- Simple -->
    <asp:Label ID="Label1" runat="server" Text="simple value" />
    
    <!-- Complex -->
    <asp:Label ID="Label1" runat="server">Complex Data including <asp:Hyperlink ID="LinkControl" runat="server" NavigateUrl="~/">link controls</asp:HyperLink></asp:Label>

    One thing you should be aware of in this situation is that the Label control wraps its contents in a <span> tag. If you want to put <p> tags in then include them in your "Complex data including..." section and then change it to an <asp:Literal> control (same syntax just use asp:Literal where you see asp:Label). The literal just dumps the contents out verbatim without wrapping it in any tags.

     

    I'm developing a site for us-EN, ca-EN, and ca-FR.

    This makes things more complex. I have never done this but I see issues with having <asp:Hyperlinks> inside localised strings. You could use a simple <a href> maybe but you should do a search on making multi lingual sites in asp.net and read a few articles to get more info on this:

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 29, 2011 5:37 PM

All replies

  • User2130758966 posted

    For simple values you can just put the value in the Text property, for complex values such as including hyperlinks you put it between the open and close tags:

    <!-- Simple -->
    <asp:Label ID="Label1" runat="server" Text="simple value" />
    
    <!-- Complex -->
    <asp:Label ID="Label1" runat="server">Complex Data including <asp:Hyperlink ID="LinkControl" runat="server" NavigateUrl="~/">link controls</asp:HyperLink></asp:Label>

    One thing you should be aware of in this situation is that the Label control wraps its contents in a <span> tag. If you want to put <p> tags in then include them in your "Complex data including..." section and then change it to an <asp:Literal> control (same syntax just use asp:Literal where you see asp:Label). The literal just dumps the contents out verbatim without wrapping it in any tags.

     

    I'm developing a site for us-EN, ca-EN, and ca-FR.

    This makes things more complex. I have never done this but I see issues with having <asp:Hyperlinks> inside localised strings. You could use a simple <a href> maybe but you should do a search on making multi lingual sites in asp.net and read a few articles to get more info on this:

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 29, 2011 5:37 PM
  • User-825324334 posted

    If you're to put large text paragraph maybe it could be interesting use a  label like this <asp:Localize runat="server" ID="par1" Text="<%$ Resources:par1 %>"/> and then in your resources file create keys where you could put large text fragment with html, for example keyname par1

    which content is ..."example text with link <a href="www.google.com" title="goole">google.com</a>". Visual studio take care about html label to put entities for each one, so they will be rendered correctly in browser,

    Hope this helps

    Saturday, April 30, 2011 4:02 AM