效果圖:
前提條件是你的網(wǎng)頁是支持utf-8,如在web.config設(shè)置如下:
復(fù)制代碼 代碼如下:
configuration>
system.web>
globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" />
/system.web>
/configuration>
.aspx:
復(fù)制代碼 代碼如下:
%@ Page Language="C#" AutoEventWireup="true" CodeFile="ShowSymbol.aspx.cs" Inherits="ShowSymbol" %>
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head runat="server">
title>/title>
/head>
body>
form id="form1" runat="server">
div>
asp:DataList ID="DataListSymbol" runat="server" RepeatColumns="9" RepeatDirection="Horizontal" Width="100%">
ItemStyle BorderStyle="Solid" BorderWidth="1px" />
ItemTemplate>
%# Eval("key") %>:nbsp;asp:Label ID="Label1" runat="server" Text='%# Eval("value") %>' ForeColor="Blue">/asp:Label>
/ItemTemplate>
/asp:DataList>
/div>
/form>
/body>
/html>
.aspx.cs:
復(fù)制代碼 代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class ShowSymbol : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Data_Binding();
}
}
private void Data_Binding()
{
this.DataListSymbol.DataSource = Symbol();
this.DataListSymbol.DataBind();
}
private Dictionarystring, string> Symbol()
{
Dictionarystring, string> sym = new Dictionarystring, string>();
sym.Add("總和", "∑");
sym.Add("全等于號", "≡");
sym.Add("正負(fù)號", "±");
sym.Add("加號;正號", "+");
sym.Add("減號;負(fù)號", "-");
sym.Add("乘號", "×");
sym.Add("除號", "÷");
sym.Add("無限大號", "∞");
sym.Add("因為", "∵");
sym.Add("所以", "∴");
sym.Add("垂直于", "⊥");
sym.Add("角", "∠");
sym.Add("圓", "⊙");
sym.Add("平方根", "√");
sym.Add("度", "°");
sym.Add("分", "′");
sym.Add("秒", "″");
sym.Add("百分之…", "%");
sym.Add("攝氏度", "℃");
sym.Add("約等于號", "≈");
sym.Add("直徑符號", "Ø");
sym.Add("四分之一符號", "¼");
sym.Add("二分之一符號", "½");
sym.Add("四分之三符號", "¾");
sym.Add("一次方符號", "¹");
sym.Add("平方符號", "²");
sym.Add("立方符號", "³");
return sym;
}
}