protected void Button1_Click(object sender, EventArgs e)
{
1. Response.Write("<script language=javascript>/r alert(/"修改失败!/");/r</script>");
2. ScriptManager.RegisterStartupScript(UpdatePanel1, typeof(UpdatePanel), "alert", "alert('你好 !');", true);
3. Page.RegisterStartupScript("alert", "<script language='javascript'>window.showModelessDialog(/"javascript:alert('你 好 !');/",/"/",/"status:no;resizable:no;help:no;dialogHeight:height:30px;dialogHeight:40px;/")</script>");
4. //ClientScript.RegisterClientScriptBlock(typeof(UpdatePanel), "alert", "<script>alert('自己看着办!')</script>", true);
}
前台页面代码;
<form id="form1" runat="server">
<div>
<div>
<asp:ScriptManager id="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:UpdatePanel id="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
<contenttemplate>
<asp:Button id="Button1" runat="server" Text="Button" OnClick="Button1_Click"></asp:Button>
</contenttemplate>
</asp:UpdatePanel>
</div>
</form>
其中第一种要加上<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
</Triggers>
下面几种不用加。
但是我观察了下,第一种,好像刷新,第二第三种不刷。第四种好像不可以,没有反应...不过网上说可以,不知了...