62,041
社区成员
发帖
与我相关
我的任务
分享
<ul>
<li><strong>北京</strong> :号码1</li>
<li style="text-indent: 57px;">号码2</li>
<li style="text-indent: 57px;">号码3</li>
....
</ul>
StringBuilder htlmstring=new StringBuilder();
string[] phone = this.zphphone.Split('/');
htlmstring="<ul><li><strong>北京</strong> :号码1</li>
for(int i=0;i<phone.length;i++)
{
htlmstring+=" <li style=\"text-indent: 57px;\">"+phone[i+1]+"</li>;
}
htlmstring+="</ul>";
literal.text=htlmstring;
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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:Literal ID="Literal1" runat="server"></asp:Literal>
</div>
</form>
</body>
</html>
using System;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Literal1.Text =
"<ul>" +
"<li><strong>北京</strong> :号码1</li>" +
//循环开始
"<li style=\"text-indent: 57px;\">号码2</li>" +
//循环结束
"</ul>";
//比较多时使用StringBuilder
}
}
}