JS中弹出确定和取消对话框并跳转页面

项目需求是查询,如果查询的值的结果为空,则跳转到另外一个页面曾新,并把查询的条件传入到新增页面

首先定义全局变量RepaterIsNull,用来标记Repeater是否为空:

private bool RepaterIsNull;

判断DataTable是否为空:

DataTable dt = bll.Search(tbSearch.Text.Trim(), aspNetPage.PageSize, aspNetPage.CurrentPageIndex, out rdCnt);
            if (dt.Rows.Count <= 0)
            {
                RepaterIsNull = true; //DataTable为空
            }
            rpt_TelBook.DataSource = dt;
            aspNetPage.RecordCount = rdCnt;
            rpt_TelBook.DataBind();

定义一个弹出对话框并跳转的方法:

protected void PopUpManager(string body,string url)
    {
        string Script;

        Script = ("<script language=javascript>");

        Script += "var retValue=window.confirm('" + body + "');" + "if(retValue){window.location='" + url + "';}";

        Script += ("</script>");

        System.Web.HttpContext.Current.Response.Write(Script);
    }

调用此方法:

protected void btnSeachPhoneNo_Click(object sender, EventArgs e)
    {
        GetTelBookList();
        string phonenumber = tbSearch.Text.Trim();
        if (RepaterIsNull)
        {
            string url = "AddTelBook.aspx?phonenumbervalues="+phonenumber;
            PopUpManager("没有此业主电话的行销记录,是否曾新?", url);
        }
    }

 

这个跳转方法参考与:http://www.zhixing123.cn/jsp/2547.html

posted on 2012-04-26 16:16  LitDev  阅读(4340)  评论(0编辑  收藏  举报