当在使用ajax的环境下,再使用Response.Write(@"<script>alert('ok')</script>")时出错,错误如下:Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed请问怎样才能解决这个问题?
谢谢

解决方案 »

  1.   

    http://www.xhsjs.com/NET/ZhiShi/100000384.shtmlScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "updateScript", "alert('删除成功!')", true);若不是在updatepanel中需要用alert提示信息,则可以使用如下代码:this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "PopWin", "<script language='javascript'>alert('投票成功!');</script>", True)此代码不能防止刷新,但是比直接写Response.Write("<script>alert('投票成功!');</script>")的用户体验要好!弹出提示框时不会造成当前页面空白
    本文来自: 小胡设计室(http://www.xhsjs.com/), 详细出处参考:http://www.xhsjs.com/NET/ZhiShi/100000384.shtml
      

  2.   

    Response.Write(@"<script>alert('ok')</script>")
    这个写法,是谁让你用的?
    居然还在AJAX语句里面用!!!!用page.registerstartupscript();
    不要用Response.Write();
      

  3.   

    用Response要刷页面Triggers节点里PostBackTrigger里指定你点击按钮的ControlID
      

  4.   

    在updatepanel里弹框ScriptManager.RegisterStartupScript(this.UpdatePanel1,this.GetType(),"", "alert('ok')", true);
      

  5.   


    对,不是在updatepanel用。
    我用this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "PopWin", "<script language='javascript'>alert('投票成功!');</script>", true)
    没有弹出对话框。注:我是在用如下的控件:
    前台:
    <ajaxToolkit:TabContainer runat="server" ID="Tabs" Height="370px" OnClientActiveTabChanged="ActiveTabChanged" ActiveTabIndex="0" Width="800px">
                <ajaxToolkit:TabPanel runat="server" ID="Panel1" HeaderText="xx管理">
                    <ContentTemplate>
                    yy:<asp:TextBox runat="server" ID="txtJobName" Width="80"/><asp:Button runat="server" ID="btnAddJobCode" Text="保存添加"/>
                    <asp:SqlDataSource runat="server" id="sds01">
                    </asp:SqlDataSource>
                    <asp:GridView id="gv01" runat="server" DataSourceID="sds01">
                    </asp:GridView>
                    </ContentTemplate>
                </ajaxToolkit:TabPanel>
    </ajaxToolkit:TabContainer>  后台:
            void btnAddJobCode_Click(object sender, EventArgs e)
            {
    ......
                if (jobname != "")
                {
                    sds01.InsertCommand = insertSQL;
                    sds01.Insert();
                    this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "zz", "<script language='javascript'>alert('OK!');</script>", true);
                }
            }
      

  6.   

    ScriptManager.RegisterStartupScript(this.btnAddJobCode,this.GetType(),"", "alert('ok')", true);
      

  7.   


    还是不行,我在网上研究RegisterStartupScript用法看看,谢谢大家。
      

  8.   

    updatepanel内不能使用response  
    ScriptManager.RegisterStartupScript(this, this.GetType(), "edit", "alert('成功')", true);   
      

  9.   


    非常感谢,这个我真还不知道,ajax了解一点皮毛,感谢指导,我得仔细学一下了!
      

  10.   


    谢谢,你这个是OK的,非常感谢!
    ajax了解不多,还真得要学学了。