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

    <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
          • W Wheels012

            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 Offline
            L Offline
            Lost User
            wrote on last edited by
            #25

            so, does this throw some exception or it renders the text with the tags ?

            W 1 Reply Last reply
            0
            • L Lost User

              so, does this throw some exception or it renders the text with the tags ?

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

              I have to declare the* id, and protected System.Web.UI.WebControls.ListItem liBullets; is incorrect. That appears to be reserved for drop-down or list boxes. I'm not sure what type the

              • is to be decalred as.
              L 1 Reply Last reply
              0
              • W Wheels012

                I have to declare the* id, and protected System.Web.UI.WebControls.ListItem liBullets; is incorrect. That appears to be reserved for drop-down or list boxes. I'm not sure what type the

                • is to be decalred as.
                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #27

                You should have told this earlier, try this:

                System.Web.UI.HtmlControls.HtmlGenericControl liBullet = new System.Web.UI.HtmlControls.HtmlGenericControl("li");

                W 1 Reply Last reply
                0
                • L Lost User

                  You should have told this earlier, try this:

                  System.Web.UI.HtmlControls.HtmlGenericControl liBullet = new System.Web.UI.HtmlControls.HtmlGenericControl("li");

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

                  What property do I use in liBullet? There doesn't seem to be a text property, and innertext didn't work.

                  L 1 Reply Last reply
                  0
                  • W Wheels012

                    What property do I use in liBullet? There doesn't seem to be a text property, and innertext didn't work.

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

                    innerText should work, what do you mean by didn't work? you mean nothing was rendered?

                    W 1 Reply Last reply
                    0
                    • L Lost User

                      innerText should work, what do you mean by didn't work? you mean nothing was rendered?

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

                      The bullet rendered, but nothing else.

                      L 1 Reply Last reply
                      0
                      • W Wheels012

                        The bullet rendered, but nothing else.

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

                        Try other alternatives suggested in this post: http://stackoverflow.com/questions/6142393/custom-control-asp-net-unordered-list-with-link-inside-lis-control[^]

                        W 1 Reply Last reply
                        0
                        • L Lost User

                          Try other alternatives suggested in this post: http://stackoverflow.com/questions/6142393/custom-control-asp-net-unordered-list-with-link-inside-lis-control[^]

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

                          Thanks for the help. We'll keeping working on it after the weekend.

                          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