当前位置:编程学习 > C#/ASP.NET >>

刷新页面时出现上次执行后的提示框

當我在頁面中執行確認按鈕后,提示成功對話框
可是當我F5刷新一次,又一次提示對話框....(這是不對的)
如何處理 --------------------编程问答-------------------- Application --------------------编程问答-------------------- 請具體寫一下嘛 --------------------编程问答-------------------- 弹出后 重加载一次页面 --------------------编程问答-------------------- 弹出确定后
在写一个语句
Response.Register(页面);
最基本的取巧、方法 --------------------编程问答-------------------- 在page_load里面寫

if(!page.ispostback)
{
}
???是這樣嗎
我是新手,能否用代易做图明示
--------------------编程问答-------------------- 我的代易做图

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
    protected void txtEmployee_TextChanged(object sender, EventArgs e)
    {
        
       
            txtEmployee.Text = txtEmployee.Text.Trim().ToString().ToUpper();
            SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["ICAS_METConnectionString"].ToString());
            string strsql = "select name from cupa01h  where employee='" + txtEmployee.Text.ToString().ToUpper() + "'";
            sqlconn.Open();
            SqlDataAdapter da = new SqlDataAdapter(strsql, sqlconn);
            DataSet data = new DataSet();
            da.Fill(data, "emp");
            if (data.Tables["emp"].Rows.Count == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('員工工號不存在!')", true);
                txtEmployee.Text = "";
                txtEmpName.Text = "";
                txtStockName.Text = "";
                txtEmployee.Focus();
                
            }
            else
            {

                txtEmpName.Text = data.Tables["emp"].Rows[0][0].ToString();
            }
            sqlconn.Close();
        
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        if (txtStock.Text.Trim().Length.Equals(0))
        {
            cvCheck.IsValid = false;
            cvCheck.ErrorMessage = "不能為空";
           return;
        }
        if (txtEmployee.Text.Trim().Length.Equals(0))
        {
            ceCheck.IsValid = false;
            ceCheck.ErrorMessage = "不能為空";
            return;
        }
        else
        {

            SqlConnection sqlslt = new SqlConnection(ConfigurationManager.ConnectionStrings["ICAS_METConnectionString"].ToString());
            sqlslt.Open();
            string strslt = "select * from icamttr_area_authority01 where mt_area+auth_type+emp_no='" + txtStock.Text.ToString() + "'+'" + ddlType.SelectedValue.ToString() + "'+'" + txtEmployee.Text + "'";
            SqlDataAdapter da = new SqlDataAdapter(strslt, sqlslt);
            DataSet data = new DataSet();
            da.Fill(data, "empt");
            if (data.Tables["empt"].Rows.Count>0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('該員工已有該庫存權限!')", true);
                sqlslt.Close();
                txtStock.Text = "";
                txtEmployee.Text = "";
                txtEmpName.Text = "";
                txtStockName.Text = "";
                txtStock.Focus();

            }
            if (data.Tables["empt"].Rows.Count == 0)
            {
         
                SqlConnection sqlinsert = new SqlConnection(ConfigurationManager.ConnectionStrings["ICAS_METConnectionString"].ToString());
                sqlinsert.Open();
                String strSql = @"insert into  
        icamttr_area_authority01
        (
        mt_area,
        auth_type,
        emp_no,
        emp_name,
        insert_datetime,
        insert_user)  
        values  
        ('"
                + txtStock.Text.ToString() + "','"
                + ddlType.SelectedValue.ToString() + "','"
                + txtEmployee.Text + "','"
                + txtEmpName.Text + "','"
                + DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") + "','" + Request.LogonUserIdentity.Name.ToUpper().Replace("ICHIA\\","") + "')";

                SqlCommand Insert_Cmd_Project = new SqlCommand(strSql, sqlinsert);
                Insert_Cmd_Project.ExecuteNonQuery();
                sqlinsert.Close();
                this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('庫存權限新增完成!')", true);
                txtStock.Text = "";
                txtEmployee.Text = "";
                txtEmpName.Text = "";
                txtStockName.Text = "";
                txtStock.Focus();
                GridView1.DataBind();
                GridView1.Visible = true;
            }
        }
    }

    protected void imagebbtSelect_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("gridview.aspx?");
    }
    protected void imagebbtCancel_Click(object sender, ImageClickEventArgs e)
    {
        ScriptManager.RegisterStartupScript(this, this.GetType(), "Query", "window.close();", true);
    }
    protected void txtStock_TextChanged(object sender, EventArgs e)
    {
        txtStock.Text = txtStock.Text.Trim().ToString().ToUpper();
        SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["ICAS_METConnectionString"].ToString());
        string strselect = "select mt_area,mt_name from  iepb07h  where mt_area='" + txtStock.Text.ToString().ToUpper() + "'";
        sqlconn.Open();
        SqlDataAdapter da = new SqlDataAdapter(strselect, sqlconn);
        DataSet data = new DataSet();
        da.Fill(data, "emp");
        if (data.Tables["emp"].Rows.Count == 0)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('庫位不符合!')", true);
            txtStock.Text = "";
            txtEmployee.Text = "";
            txtEmpName.Text = "";
            txtStockName.Text = "";
            txtStock.Focus();
        }
        else
        {

            txtStockName.Text = data.Tables["emp"].Rows[0][1].ToString();
        }

        sqlconn.Close();

    }
}
--------------------编程问答-------------------- 這樣不行吧,我好多判斷語句,當我提示某一個的時候,去刷新一次都會顯示上次提示的內容,難道還每個提示語句下面都來個這個吧....因該整體的來看,要刷新的時候,刷新到剛開始進來的畫面,其他都不執行 --------------------编程问答-------------------- 提交后刷新默认又提交了一次!
提交后最后重新加载页面:response.redirect --------------------编程问答-------------------- 能否用其他方式.
請用代易做图明示
Response.Redirect("index.aspx?");效果不是很好 --------------------编程问答-------------------- ClientScript.RegisterStartupScript
改成
clientscript.RegisterClientScriptBlock
试一下 --------------------编程问答-------------------- 不行,刷新的時候,還是會出現 --------------------编程问答-------------------- this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('庫位不符合!'); window.location.href = window.location.href;", true); 
补充:.NET技术 ,  C#
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,