Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
public partial class WebForm1 : System.Web.UI.Page { string timedate = DateTime.Now.ToString("MM/dd/yyyy HH:mm:tt"); protected void Page_Load(object sender, EventArgs e) { }
如果我理解正确并且您需要在 2 个页面(网络表单)之间共享数据,您可以使用 Session:
例如在一页上:
string timedate = DateTime.Now.ToString("MM/dd/yyyy HH:mm:tt"); Session["timedate"] = timedate;
在另一页上:
string timedate; if (Session["timedate"] != null) { timedate = Session["timedate"].ToString(); }