Code for displaying mathematical symbols on the asp.net webpage

Source: Internet
Author: User

:

The precondition is that your webpage supports UTF-8. For example, the settings in web. config are as follows:
Copy codeThe Code is as follows:
<Configuration>
<System. web>
<Globalization fileEncoding = "UTF-8" requestEncoding = "UTF-8" responseEncoding = "UTF-8"/>
</System. web>
</Configuration>

. Aspx:
Copy codeThe Code is as follows:
<% @ 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") %>: <asp: Label ID = "Label1" runat = "server" Text = '<% # Eval ("value ") %> 'forecolor = "Blue"> </asp: Label>
</ItemTemplate>
</Asp: DataList>
</Div>
</Form>
</Body>
</Html>

. Aspx. cs:
Copy codeThe Code is as follows:
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 Dictionary <string, string> Symbol ()
{
Dictionary <string, string> sym = new Dictionary <string, string> ();
Sym. Add ("sum", "Σ ");
Sym. Add ("all equal signs", "allow ");
Sym. Add ("Positive and Negative", "± ");
Sym. Add ("plus sign; Positive", "+ ");
Sym. Add ("minus sign; minus sign ","-");
Sym. Add ("multiplication", "× ");
Sym. Add ("except", "allow ");
Sym. Add ("unlimited", "∞ ");
Sym. Add ("because", "role ");
Sym. Add ("so", "role ");
Sym. Add ("vertical to", "vertical ");
Sym. Add ("", "role ");
Sym. Add ("circle", "⊙ ");
Sym. Add ("square root", "√ ");
Sym. Add ("degree", "° ");
Sym. Add ("points ","′");
Sym. Add ("seconds ","″");
Sym. Add ("%... "," % ");
Sym. Add ("Celsius", "℃ ");
Sym. Add ("approx. equal to", "≈ ");
Sym. Add ("diameter symbol", "Ø ");
Sym. Add ("1/4", "Hangzhou ");
Sym. Add ("1/2", "Hangzhou ");
Sym. Add ("3/4", "Hangzhou ");
Sym. Add ("", "¹ ");
Sym. Add ("square symbol", "² ");
Sym. Add ("cube", "cube ");
Return sym;
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.