开发者

Asp.Net DropDownList problem with apostrophies

I'm adding a record to a DropDownList with the following code

this.ddlLocation.Items.Add(new ListItem(hs.ToString(), ll.id));

This works correctly for normal strings however if there is an apostrophe in the string it comes out in html as

<option value="11">Queen&amp;amp;apos;s University</option>

where it should have been Queen's University. I have checked the value immediately before passing the string and it's how it should be. It looks like it is being encoded twice so the original apostrope is taken out followed by the ampersand exit character. I'm not sure where the encodes are happening and how to miss one of them out.

Also I'm using .Net 4.0

Thanks

Added the full html for the drop down.

<div class="fieldCol">
                            <label for="peopleSearch_lawSchool">LawSchool</label>
                            <select name="ctl00$nrContentPlaceHolder$ddlLawSchool" id="nrContentPlaceHolder_ddlLawSchool" class="peopleSearch_lawSchool" name="peopleSearch_lawSchool">
    <option value="0">All</option>
    <option value="1">Boston University</option>
    <option value="2">Columbia University</option>
    <option value="3">Cornell Law School</option>
    <option value="4">Dalhousie University</option>
    <option value="5">HEC Montr&#233;al</option开发者_StackOverflow社区>
    <option value="6">London School of Economics and Political Science</option>
    <option value="7">Loyola University</option>
    <option value="8">Magdalene College - Cambridge</option>
    <option value="9">McGill University</option>
    <option value="10">Osgoode Hall Law School</option>
    <option value="11">Queen&amp;amp;apos;s University</option>
    <option value="12">Symbiosis Law College</option>
    <option value="13">Universit&#233; de Moncton</option>
    <option value="14">Universit&#233; de Montr&#233;al</option>
    <option value="15">Universit&#233; de Sherbrooke</option>
    <option value="16">Universit&#233; du Qu&#233;bec &#224; Montr&#233;al</option>
    <option value="17">Universit&#233; Laval</option>
    <option value="18">Universit&#233; Paris X</option>
    <option value="19">University of Alberta</option>
    <option value="20">University of Birmingham</option>
    <option value="21">University of British Columbia</option>
    <option value="22">University of Bucharest</option>
    <option value="23">University of Calgary</option>
    <option value="24">University of California</option>
    <option value="25">University of Cambridge</option>
    <option value="26">University of Detroit Mercy School of Law</option>
    <option value="27">University of Glasgow</option>
    <option value="28">University of London</option>
    <option value="29">University of London, England</option>
    <option value="30">University of Manitoba</option>
    <option value="31">University of New Brunswick</option>
    <option value="32">University of Ottawa</option>
    <option value="33">University of Oxford</option>
    <option value="34">University of Pennsylvania</option>
    <option value="35">University of Pune</option>
    <option value="36">University of Toronto</option>
    <option value="37">University of Victoria</option>
    <option value="38">University of Western Ontario</option>
    <option value="39">University of Windsor</option>

</select>
                        </div>

It is using a asp:dropdownlist


I'm not sure if you can suppress encoding in the DropDownList, so I'd recommend looking at where did hs get encoded to see if you can fix that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜