![](/img/trans.png)
[英]in c#, how to display array of string in dropdownlist using label control?
[英]How to display a Superscript in C# Dropdownlist, using html tags
希望有人能告訴我如何在下拉列表選項的文本中正確顯示像²這樣的Superscript標簽?
謝謝。
可能使用HTML實體:
²
而不是實際的角色。 但讓C#處理它可能更好:
string safeString = HttpUtility.HtmlEncode("your string²");
// Use the result as the displayed value in your Dropdownlist
此方法還會找到其他有問題的字符,例如&,並相應地替換它們。 有關詳細信息,請參閱MSDN HttpUtility.HtmlEncode 。
編輯 :被告知; 來自HtmlEncode的結果字符串將顯示(在HTML中使用時)與您在方法中輸入的內容完全相同。 因此,不要在輸入中使用HTML實體,因為這正是您在結果頁面中看到的內容。
如果你想顯示m²,那么只需在方法內輸入。 .NET將負責其余部分。
也許unicode符號可以幫到你: http : //tlt.its.psu.edu/suggestions/international/bylanguage/mathchart.html#super
對於上標兩個,你會使用²
導致:²
你可以這樣寫,
string item=HttpUtility.HtmlDecode("ml/min/1.73m²")
有關上標的更多信息,您可以看到此鏈接http://symbolcodes.tlt.psu.edu/bylanguage/mathchart.html#super
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.