ASP.NET Web窗体中的通知消息

时间:2013-06-04 13:02:32

标签: asp.net

您能否告诉我如何在ASP.NET Web窗体中进行通知,例如在ASP.NET MVC中,我们有TempData,如:

[HttpPost]
public ActionResult DoSomething(Customer c) {

   TempData["custdetails"] = "Thx for message";

   return RedirectToAction("Index");

}

<div>
 @if (TempData["custdetails"] != null) {

 <p>@TempData["custdetails"]</p>

 }
</div>

1 个答案:

答案 0 :(得分:0)

您可以使用服务器标签通过javascript警报输入服务器值。

<强>的.cs

protected void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        Session["msg"] = "Page Loaded!!!";       
    }
}

<强>的.aspx

<script type="text/javascript">
  alert("<%= Session["msg"].ToString() %>");
</script>