Prevent ASP.NET from encoding strings on output

Posted by Darkwater23 on Stack Overflow See other posts from Stack Overflow or by Darkwater23
Published on 2010-05-11T19:15:48Z Indexed on 2010/05/12 5:24 UTC
Read the original article Hit count: 224

Filed under:
|

How can I stop ASP.Net from encoding anchor tags in List Items when the page renders?

I have a collection of objects. Each object has a link property. I did a foreach and tried to output the links in a BulletedList, but ASP encoded all the links.

Any idea? Thanks!

Here's the offending snippet of code. When the user picks a specialty, I use the SelectedIndexChange event to clear and add links to the BulletedList:

if (SpecialtyList.SelectedIndex > 0)
    {
        PhysicianLinks.Items.Clear();

        foreach (Physician doc in docs)
        {
            if (doc.Specialties.Contains(SpecialtyList.SelectedValue))
            {
                PhysicianLinks.Items.Add(new ListItem("<a href=\"" + doc.Link + "\">" + doc.FullName + "</a>"));    
            }
        }
    }

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about encoding