一个button类型的web控件,在它的事件函数中判断出一种情况,然后弹出警告框,但是弹出了这个警告框之后,背景页面就变白了,整个页面刷新了。有什么办法不让它变白吗?不要说在前台页面写js哦,有没有办法在后台实现?

解决方案 »

  1.   

    protected void btn_OnClick(object o, EventArgs e)
        {
           // Page.RegisterClientScriptBlock("onclick", "<script>alert('alert!!alert!!');</script>");  这个会刷新
            Page.RegisterStartupScript("onclick", "<script>alert('alert!!alert!!');</script>");
        }
      

  2.   

    楼主还没明白前台与后台的关系,这种需求99%用前台js来实现,特殊需求的1%可能用ajax实现。
      

  3.   

    String csname1 = "PopupScript";
    Type cstype = this.GetType();       ClientScriptManager cs = Page.ClientScript;        if (!cs.IsStartupScriptRegistered(cstype, csname1))
            {
                String cstext1 = "alert('Hello World');";
                cs.RegisterStartupScript(cstype, csname1, cstext1, true);
            }
      

  4.   

    Response.write("<script defer>alert('alert!!alert!!');</script>");
      

  5.   

    2003:RegisterStartupScript(Page)
    2005:RegisterClientScriptBlock(ClientScript)
      

  6.   

    Response.write("<script defer>alert('Warning!!');</script>");
      

  7.   

    用那个注册之后再发js的方法还是不行,页面在回发之后,没有展现完毕就弹出警告框了,不知道是不是我建的是Ajax的原因?