一分耕耘,一分收获

编程路上的成长与收获

 

ajax updatepannel中response.write()问题

今天又遇到这个问题,搜了下,整理了看,大概西面三种方法可以解决问题:

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>

下面几种不用加。

但是我观察了下,第一种,好像刷新,第二第三种不刷。第四种好像不可以,没有反应...不过网上说可以,不知了...

posted on 2007-11-15 09:34  如烟  阅读(1058)  评论(0)    收藏  举报

导航