方法1:p1.InnerHtml = item;//p1是p标签的id
方法2:定义全局变量
public static string f;
protected void Button2_Click(object sender, EventArgs e)
{
foreach (string item in list)
{
f = item;//把item赋值给全局变量:
//p1.InnerHtml = item;
Response.Write(item);
string a = item;
string b = Session["demo"].ToString();
}
前台接受值<p id="p1" runat="server"><%=f%></p>//(<%=f%>)接收变量的值