HyperLink in InnerHtml or Innertext

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rrocket
    New Member
    • Aug 2007
    • 116

    HyperLink in InnerHtml or Innertext

    I am creating a table through the codebehind with info from a XML string. I would like to create a link from the text in one of the cells.

    Here is the best example that I came up with of what I need to do:
    [code=C#]
    string linkstring = "<a href=\"http://website.com?Tra ckingNum=" + sArray[TrackNum] + ">" + sArray[TrackNum] + "</a>";

    TrackDetailsCel l.InnerText = linkstring;
    //or
    TrackDetailsCel l.InnerHtml = linkstring;
    [/code]

    I need to have some info in the link so that another page can pull the values from the query string. Any ideas of how to get this to work? Thanks.
    Last edited by rrocket; Mar 24 '08, 09:28 PM. Reason: Just cleaned the format up a bit so it reads a little better.
  • kunal pawar
    Contributor
    • Oct 2007
    • 297

    #2
    did u read about table control. this property is not support for table control. so u have u used another way.
    U should use repeater / datalist control also. or u can create table from code behind

    Comment

    • rrocket
      New Member
      • Aug 2007
      • 116

      #3
      Originally posted by kunal pawar
      did u read about table control. this property is not support for table control. so u have u used another way.
      U should use repeater / datalist control also. or u can create table from code behind
      I actually am creating the tables from the codebehind. Here is what I was looking for.

      [code=C#]
      //This will create the hyperlink
      HyperLink TrackNumLink = new HyperLink();
      TrackNumLink.Te xt = sArray[TrackNum];
      TrackNumLink.Na vigateUrl = "http://www.website.com ?TrackingNum=" + sArray[TrackNum];

      //This will apply it to the cell of choice
      TrackDetailsCel l.Controls.Add( TrackNumLink);
      [/code]

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        The backend code version of tables automatically escapes text you put in it (so putting in HTML code like your first try would get escaped into things like &lt; and such). Using the HyperLink object is the way to go.

        Comment

        Working...