前台页面
<div><%= Name %></div><div><%= getName() %></div>
后台代码
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;namespace WebApplication1{public partial class WebForm1 : System.Web.UI.Page{public string Name = \"我是来自后台变量的名字\";protected void Page_Load(object sender, EventArgs e){}public string getName(){return \"我是来自后台方法的名字\";}}}
效果图