62,041
社区成员
发帖
与我相关
我的任务
分享
//重新载入页面,不会造成页面混乱
public void ShowMsg(string messagest, string url)
{
Response.Write("<script language='javascript'>alert('" + messagest+ "');</script>");
Response.Write("<script language='javascript'>window.location.href='" + url + "';</script>");
}
public void ShowMsg(string messagest)
{
Response.Write("<script language='javascript'>alert('" + messagest+ "');</script>");
}
//补充个方法,实现重载
/跳转页面
public void ShowMsg(string messages)
{
Response.Write("<script language='javascript'>alert('" + messagest+ "');</script>");
}
protected void btnSave_Click(object sender, EventArgs e)
{
//省略了创建实体类的代码
int result = custManage.AddNewCustomer(cust, fk);//访问数据的方法
if (result > 0)
{
ShowMsg("新客户添加成功!", "../CustomerList.aspx");
}
else
{
ShowMsg("客户添加失败!");
}
}
//跳转页面
public void ShowMsg(string messagest, string url)
{
Response.Write("<script language='javascript'>alert('" + messagest+ "');</script>");
Response.Write("<script language='javascript'>window.location.href='" + url + "';</script>");
}
/// <summary>
/// 提示警告后跳转
/// </summary>
/// <returns></returns>
protected void ClientScriptAlert(string alertText, string href)
{
if (string.IsNullOrEmpty(href))
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + alertText + "');</script>");
}
else
{
this.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + alertText + "');location.href='" + href + "';</script>");
}
}