日期:2014-05-18  浏览次数:20484 次

asp.net 点击页面上的按钮后执行更新数据库的操作,操作完毕后在显示“更新成功”的对话框怎么实现?
protected void ButtonSave_Click(object sender, EventArgs e)
{
  using (OracleConnection conn = new OracleConnection())
  {
  conn.ConnectionString = "Data Source=*.world;User ID=*;Password=*";

  OracleCommand cmd = new OracleCommand();
  cmd.Connection = conn;
  cmd.CommandText = "insert into TEST_1(ID, NAME, AGE, BIRTH) values(:ID, :NAME, :AGE, :BIRTH)";

  OracleParameter param = new OracleParameter("ID", OracleType.Int32);  
  //省略...
   
  conn.Open();
  cmd.ExecuteNonQuery();
  }
  Literal txtMsg = new Literal();
txtMsg.Text = "<script>alert('更新成功!')</script>";
Page.Controls.Add(txtMsg);
}

除此之外还有什么方法?

------解决方案--------------------
ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('更新成功!')</script>");
------解决方案--------------------
Page.RegisterStartupScript("warnings", "<script>alert('更新成功!');</script>")
------解决方案--------------------
Page.RegisterStartupScript("warnings", " <script> alert('更新成功!'); </script> ")
------解决方案--------------------
C# code

Response.Write("   <script       language=javascript>   alert("更新成功")   </script>   "); //这个要出现一个白色的页面,在出现文本框
Page.RegisterStartupScript(""," <script       language=javascript>   alert("更新成功")   </script> ");
//这个在本页出现文本框