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>

下面幾種不用加。

但是我觀察了下,第一種,好像刷新,第二第三種不刷。第四種好像不可以,沒有反應...不過網上說可以,不知了...

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章