Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Adding a hyperlink to a sentence of text in a bulleted list

Adding a hyperlink to a sentence of text in a bulleted list

Scheduled Pinned Locked Moved C#
helptutorialquestion
32 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Wheels012

    private const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page>Test Page\"</a> where people click to navigate to another page.";

    B Offline
    B Offline
    BobJanova
    wrote on last edited by
    #5

    Your HTML is invalid (the quotes around the attribute value aren't done right).

    W 1 Reply Last reply
    0
    • B BobJanova

      Your HTML is invalid (the quotes around the attribute value aren't done right).

      W Offline
      W Offline
      Wheels012
      wrote on last edited by
      #6

      Hi Bob. What should they be? WHEELS

      B L 2 Replies Last reply
      0
      • W Wheels012

        Hi Bob. What should they be? WHEELS

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #7

        private const string BULLETTHREELBHL = "This is an example of the hyperlink Test Page where people click to navigate to another page.";

        EDIT: If it still doesn't work, make sure that it is not Html encoded before being rendered. For example. The Text property of some controls automatically Html encode their content. So if you put html tags inside the Text property, they'll be renedered as html tags.

        1 Reply Last reply
        0
        • W Wheels012

          Hi Bob. What should they be? WHEELS

          B Offline
          B Offline
          BobJanova
          wrote on last edited by
          #8

          private const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page\">Test Page</a> where people click to navigate to another page.";

          If you can't fix mistakes like that in HTML then why are you writing websites ...

          W 1 Reply Last reply
          0
          • B BobJanova

            private const string BULLETTHREELBHL = "This is an example of the hyperlink <a href=\"/../Test/FW_DEFAULT.ASPX?Serviceid=Test&title=Test+Page\">Test Page</a> where people click to navigate to another page.";

            If you can't fix mistakes like that in HTML then why are you writing websites ...

            W Offline
            W Offline
            Wheels012
            wrote on last edited by
            #9

            Thanks Bob and Shameel. We had done some modifications to this code and when we put it back, we must have put the syntax back incorrectly. Unfortunately after fixing the code, it still renders as text. WHEELS

            B L 2 Replies Last reply
            0
            • W Wheels012

              Thanks Bob and Shameel. We had done some modifications to this code and when we put it back, we must have put the syntax back incorrectly. Unfortunately after fixing the code, it still renders as text. WHEELS

              B Offline
              B Offline
              BobJanova
              wrote on last edited by
              #10

              You still haven't shown the code that actually renders this text. Do other HTML tags work correctly? If your user control simply renders the text literally into the HTML stream then it should work so I'm guessing something is wrong in that area.

              1 Reply Last reply
              0
              • W Wheels012

                Thanks Bob and Shameel. We had done some modifications to this code and when we put it back, we must have put the syntax back incorrectly. Unfortunately after fixing the code, it still renders as text. WHEELS

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #11

                It is being Html encoded before being rendered. As I said in my previous post, certain controls automatically html encode their content before rendering. Just to test if that is the actual problem, try using a div tag (HtmlGenericControl) and set its innerText property to the desired html output.

                W 2 Replies Last reply
                0
                • L Lost User

                  It is being Html encoded before being rendered. As I said in my previous post, certain controls automatically html encode their content before rendering. Just to test if that is the actual problem, try using a div tag (HtmlGenericControl) and set its innerText property to the desired html output.

                  W Offline
                  W Offline
                  Wheels012
                  wrote on last edited by
                  #12

                  Hi Shameel. The text renders correctly when set up as a label directly on the page. I believe you are correct about the encoding issue. Is there a way to decode? WHEELS

                  L 1 Reply Last reply
                  0
                  • W Wheels012

                    Hi Shameel. The text renders correctly when set up as a label directly on the page. I believe you are correct about the encoding issue. Is there a way to decode? WHEELS

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #13

                    It depends on how you render the output. You have still not shown the code that actually renders your html output.

                    1 Reply Last reply
                    0
                    • L Lost User

                      It is being Html encoded before being rendered. As I said in my previous post, certain controls automatically html encode their content before rendering. Just to test if that is the actual problem, try using a div tag (HtmlGenericControl) and set its innerText property to the desired html output.

                      W Offline
                      W Offline
                      Wheels012
                      wrote on last edited by
                      #14

                      I had to abandon the Common control approach. I added a simple BulletedList to the .aspx file, but I am still having a very challenging time setting a hyperlink on a given word in a bullet sentence. I am starting to believe this can't be done. There are three DisplayMode options for a BulletedList: Text, HyperLink, and ImageButton, but no Text/Hyperlink combo. If you have time can you try to create one that does what I am looking for? Thanks, WHEELS

                      L 1 Reply Last reply
                      0
                      • W Wheels012

                        I had to abandon the Common control approach. I added a simple BulletedList to the .aspx file, but I am still having a very challenging time setting a hyperlink on a given word in a bullet sentence. I am starting to believe this can't be done. There are three DisplayMode options for a BulletedList: Text, HyperLink, and ImageButton, but no Text/Hyperlink combo. If you have time can you try to create one that does what I am looking for? Thanks, WHEELS

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #15

                        Bulleted list and hyperlink will definitely work. Try this:

                        • Google
                        • Bing
                        W 1 Reply Last reply
                        0
                        • L Lost User

                          Bulleted list and hyperlink will definitely work. Try this:

                          • Google
                          • Bing
                          W Offline
                          W Offline
                          Wheels012
                          wrote on last edited by
                          #16

                          Sorry Shameel. I was not entirely clear. I have done that sucessfully, but what I am looking for is the following: * This is an example of programming. Then when you click the underlined word good it takes you to http://www.codeproject.com. * is a bullet. WHEELS

                          L 1 Reply Last reply
                          0
                          • W Wheels012

                            Sorry Shameel. I was not entirely clear. I have done that sucessfully, but what I am looking for is the following: * This is an example of programming. Then when you click the underlined word good it takes you to http://www.codeproject.com. * is a bullet. WHEELS

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #17

                            I dont see any problem with that too:

                            • To Access Google, click here
                            • This takes you to Bing
                            W 1 Reply Last reply
                            0
                            • L Lost User

                              I dont see any problem with that too:

                              • To Access Google, click here
                              • This takes you to Bing
                              W Offline
                              W Offline
                              Wheels012
                              wrote on last edited by
                              #18

                              It seems to work well in the .aspx, but now I have to put it in as a dynamic variable. Is there any issue with including the a href in the string? WHEELS

                              L 1 Reply Last reply
                              0
                              • W Wheels012

                                It seems to work well in the .aspx, but now I have to put it in as a dynamic variable. Is there any issue with including the a href in the string? WHEELS

                                L Offline
                                L Offline
                                Lost User
                                wrote on last edited by
                                #19

                                Depends on how you put the 'href' within that string. As long as the correct html is rendered, you shouldn't have any problem. Can you care to show me your entire code that renders the output?

                                W 1 Reply Last reply
                                0
                                • L Lost User

                                  Depends on how you put the 'href' within that string. As long as the correct html is rendered, you shouldn't have any problem. Can you care to show me your entire code that renders the output?

                                  W Offline
                                  W Offline
                                  Wheels012
                                  wrote on last edited by
                                  #20

                                  <ul>
                                  <li id="liBullet" />
                                  <li><a href="http://bing.com">This</a> takes you to Bing</li>
                                  </ul>

                                  C#

                                  protected System.Web.UI.WebControls.ListItem liBullet;
                                  this.liBullet.Attributes.Add(BULLETTHREELBHL);
                                  private const string BULLETTHREELBHL = "Employee earnings can be submitted through the <a href=\"/EECHG/FW_DEFAULT.ASPX?Serviceid=EECHG&title=Employee+Changes\">Employee Changes</a> service by a plan administrator with access to update employee changes.";

                                  WHEELS

                                  L 1 Reply Last reply
                                  0
                                  • W Wheels012

                                    <ul>
                                    <li id="liBullet" />
                                    <li><a href="http://bing.com">This</a> takes you to Bing</li>
                                    </ul>

                                    C#

                                    protected System.Web.UI.WebControls.ListItem liBullet;
                                    this.liBullet.Attributes.Add(BULLETTHREELBHL);
                                    private const string BULLETTHREELBHL = "Employee earnings can be submitted through the <a href=\"/EECHG/FW_DEFAULT.ASPX?Serviceid=EECHG&title=Employee+Changes\">Employee Changes</a> service by a plan administrator with access to update employee changes.";

                                    WHEELS

                                    L Offline
                                    L Offline
                                    Lost User
                                    wrote on last edited by
                                    #21

                                    Attributes.Add() method takes 2 arguments, this code shouldn't compile at all. You should ideally be using ListItem.Text property to render your output.

                                    W 1 Reply Last reply
                                    0
                                    • L Lost User

                                      Attributes.Add() method takes 2 arguments, this code shouldn't compile at all. You should ideally be using ListItem.Text property to render your output.

                                      W Offline
                                      W Offline
                                      Wheels012
                                      wrote on last edited by
                                      #22

                                      When I dynamically populate the .text property, I get an Object reference not set to an instance of an object error. System.NullReferenceException.

                                      L 1 Reply Last reply
                                      0
                                      • W Wheels012

                                        When I dynamically populate the .text property, I get an Object reference not set to an instance of an object error. System.NullReferenceException.

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #23

                                        Can you show the code here?

                                        W 1 Reply Last reply
                                        0
                                        • L Lost User

                                          Can you show the code here?

                                          W Offline
                                          W Offline
                                          Wheels012
                                          wrote on last edited by
                                          #24

                                          protected System.Web.UI.WebControls.ListItem liBullets;

                                          private const string BULLETTHREELBHL = "Employee earnings can be submitted through the <a href=\"/EECHG/FW_DEFAULT.ASPX?Serviceid=EECHG&title=Employee+Changes\">Employee Changes</a> service by a plan administrator with access to update employee changes.";

                                          this.liBullets.Text = BULLETTHREELBHL;

                                          <ul>
                                          <li id="liBullets" />
                                          <li>To Access Google, click <a href="http://google.com">here</a></li>
                                          <li><a href="http://bing.com">This</a> takes you to Bing</li>
                                          </ul>

                                          L 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups