关于AJAX应用于web网页,如何弹出对话框的几种常用方法【用的时候直接调用即可】

前端之家收集整理的这篇文章主要介绍了关于AJAX应用于web网页,如何弹出对话框的几种常用方法【用的时候直接调用即可】前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
/// <summary>显示消息提示对话框
/// 显示消息提示对话框
/// </summary>
/// <param name="page">当前页面指针,一般为this</param>
/// <param name="msg">提示信息</param>
public void Show(System.Web.UI.Page page,string msg)
{

//page.RegisterStartupScript("message","<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
page.ClientScript.RegisterStartupScript(page.GetType(),"message","<script language='javascript' defer>alert('" + msg.ToString() + "');</script>");
}

/// <summary>
/// 控件点击消息确认提示
/// </summary>
/// <param name="page">当前页面指针,一般为this</param>
/// <param name="msg">提示信息</param>
public void ShowConfirm(System.Web.UI.WebControls.WebControl Control,string msg)
{
Control.Attributes.Add("onclick","return confirm('" + msg + "');");
}


/// <summary>
/// 显示消息提示对话框,并进行页面跳转
/// </summary>
/// <param name="page">当前页面指针,一般为this</param>
/// <param name="msg">提示信息</param>
/// <param name="url">跳转的目标URL</param>
public void ShowAndRedirect(System.Web.UI.Page page,string msg,string url)
{
StringBuilder Builder = new StringBuilder();
Builder.Append("<script language='javascript' defer>");
Builder.AppendFormat("alert('{0}');",msg);
Builder.AppendFormat("top.location.href='{0}'",url);
Builder.Append("</script>");
// page.RegisterStartupScript("message",Builder.ToString());
page.ClientScript.RegisterStartupScript(page.GetType(),Builder.ToString());
}
/// <summary>
/// Ajax弹出对话框
/// </summary>
/// <param name="control">一般为UpdataPanle</param>
/// <param name="type">this.Gettype()</param>
/// <param name="script">提示信息</param>
public void AjaxResponeSrcipt(System.Web.UI.Control control,Type type,string script)
{
ScriptManager.RegisterClientScriptBlock(control,type,"click","alert('"+script+"')",true);

}

【实例应用:】

msgBox.AjaxResponeSrcipt(UpdatePanel1,this.GetType(),"请输入正确的信息!");


/// <summary>
/// Ajax@R_617_404@面
/// </summary>
/// <param name="control">一般为UpdataPanle</param>
/// <param name="type">this.Gettype()</param>
/// <param name="script">js脚本</param>
public void AjaxTiaoZhuan(System.Web.UI.Control control,string script)
{
ScriptManager.RegisterStartupScript(control,"alert",script,true);
}


public void AjaxResponeSrciptAndBack(System.Web.UI.Control control,string script)
{
ScriptManager.RegisterClientScriptBlock(control,"alert('" + script + "');history.go(-1);",true);
}


public void AjaxResponeSrciptAndClose(System.Web.UI.Control control,string script)
{
ScriptManager.RegisterClientScriptBlock(control,"alert('" + script + "');window.close();",true); } 原文链接:https://www.f2er.com/ajax/165330.html

猜你在找的Ajax相关文章