ITPub博客

首页 > Linux操作系统 > Linux操作系统 > UpdatePanel下解决提示框不弹出的方法

UpdatePanel下解决提示框不弹出的方法

原创 Linux操作系统 作者:taogchan 时间:2013-01-31 14:13:36 0 删除 编辑

用户体验上既想页面不刷新,也希望同时能够看到操作的效果(弹出提示框)!


①不刷新,我们可以使用UpdatePanel


②弹出消息框,这个有很多的方式:我写两个作为例子参考一下!


eg:Response.Write("alert('产品添加成功!')");


ClientScript.RegisterStartupScript(this.GetType(), "", "alert('产品添加成功!');");


但是但这两个搞到一起的时候,我去,提示框没效果了!


下面给大家提供两个方法:



#region updatepanle下解决提示框不弹出的方法
    /// 
    /// 弹出消息框并且转向到新的URL
    /// 
    /// 控件名称
    /// 消息内容
    /// 连接地址
    public static void AlertAndRedirect(Control controlName, string message, string toURL)
    {
        #region
        string sMessage = ErrMsg(message);
        ScriptManager.RegisterClientScriptBlock(controlName, typeof(UpdatePanel), "提示", "alert('" + message + "');location.href='" + toURL + "'", true);
        #endregion
    }

    /// 
    /// 弹出消息框
    /// 
    /// 控件名称
    /// 消息内容
    public static void AlertMsgAndNoFlush(Control controlName, string message)
    {
        string sMessage = ErrMsg(message);
        ScriptManager.RegisterClientScriptBlock(controlName, typeof(UpdatePanel), "提示", "alert('" + message + "');", true);

    }



PS:控件名称一般是UpdatePanel的ID(例如:UpdatePanel1)


eg:AlertAndRedirect(UpdatePanel1,"产品添加成功!","http://www.baidu.com");


AlertMsgAndNoFlush(UpdatePanel1,"产品添加成功!");

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22392018/viewspace-753662/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-08-28

  • 博文量
    196
  • 访问量
    1242420