警报消息显示是和否

警报消息显示是和否

本文介绍了警报消息显示是和否的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,用户每次单击提交按钮时都可以在其中输入不同的数据。问题在于它处于循环中。这就是我想要的,但我想添加其他东西。当用户点击提交按钮时,我想显示一条警告消息,询问你还有另一个要进入吗?按钮是和否。如果用户单击是,则消息将消失,页面将以空白表单刷新。如果用户单击否,则将用户重定向到主页。有人能告诉我这是怎么做到的吗?



I have a form that a user can enter different data into it every time the submit button is clicked. The issue is that it is in a loop. This is what I want but I wanted to add something else. When the user clicks on the submit button I would like to display an alert message that ask, " Do you have another to enter?" with the buttons yes and no on it. If the user clicks yes the message goes away and the page refreshes with a blank form. If the user clicks no the user is redirected to the home page. Can someone show me how this is done?

protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
        con.Open();

        SqlCommand cmd = new SqlCommand("Insert into Table50 (INST_ID, TOTAL_REVE, DATE, FINYR, INSTRUCTIO, RESEARCH, ACADEMIC_S, NET_AID, AUXILIARY_, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT) values (@INST_ID, @TOTAL_REVE, @DATE, @FINYR, @INSTRUCTIO, @RESEARCH, @ACADEMIC_S, @NET_AID, @AUXILIARY_, @OTHEREXP, @TOTASSETS, @TOTLIABILITY, @NoNEXPPERMRESASSETS, @UNRNETASSETS, @TOTALREV, @TUITFEES, @CURRDEBT, @LONGTERMDEBT)Insert into Table55 (INST_ID, TOTAL_REVE, DATE, FINYR, INSTRUCTIO, RESEARCH, ACADEMIC_S, NET_AID, AUXILIARY_, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT) values (@INST_ID, @TOTAL_REVE, @DATE, @FINYR, @INSTRUCTIO, @RESEARCH, @ACADEMIC_S, @NET_AID, @AUXILIARY_, @OTHEREXP, @TOTASSETS, @TOTLIABILITY, @NoNEXPPERMRESASSETS, @UNRNETASSETS, @TOTALREV, @TUITFEES, @CURRDEBT, @LONGTERMDEBT)", con);

        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@INST_ID", TextBoxINST_ID.Text);
        cmd.Parameters.AddWithValue("@TOTAL_REVE", TextBoxTRR.Text);
        cmd.Parameters.AddWithValue("@INSTRUCTIO", TextBoxInstr.Text);
        cmd.Parameters.AddWithValue("@RESEARCH", TextBoxResPs.Text);
        cmd.Parameters.AddWithValue("@ACADEMIC_S", TextBoxAcadSSSIS.Text);
        cmd.Parameters.AddWithValue("@NET_AID", TextBoxNGAS.Text);
        cmd.Parameters.AddWithValue("@AUXILIARY_", TextBoxAuxE.Text);
        cmd.Parameters.AddWithValue("@OTHEREXP", TextBoxAOE.Text);
        cmd.Parameters.AddWithValue("@TOTASSETS", TextBoxTA.Text);
        cmd.Parameters.AddWithValue("@TOTLIABILITY", TextBoxTL.Text);
        cmd.Parameters.AddWithValue("@NoNEXPPERMRESASSETS", TextBoxNPRNA.Text);
        cmd.Parameters.AddWithValue("@EXPENDABLE", TextBoxETRNA.Text);
        cmd.Parameters.AddWithValue("@UNRNETASSETS", TextBoxTUNA.Text);
        cmd.Parameters.AddWithValue("@TOTALREV", TextBoxTR.Text);
        cmd.Parameters.AddWithValue("@TUITFEES", TextBoxTFN.Text);
        cmd.Parameters.AddWithValue("@CURRDEBT", TextBoxCD.Text);
        cmd.Parameters.AddWithValue("@LONGTERMDEBT", TextBoxLTD.Text);
        cmd.Parameters.AddWithValue("@FINYR", lblYEAR.Text);
        cmd.Parameters.AddWithValue("@DATE", TextBoxDATE.Text);

        cmd.ExecuteNonQuery();
        con.Close();

        if (Page.IsValid)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('You Have Successfully Submitted the Financial Profile');", true);
        }

推荐答案

location.reload()

重新加载/刷新页面。



如果用户点击取消



使用

which reloads/refreshes the page.

if User clicks Cancel

use

location.href='anotherpage.aspx';





示例代码:





Sample code :

Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "if(confirm('You Have Successfully Submitted the Financial Profile?') == true){ location.reload();}else{location.href='anotherpage.aspx';}", true);





希望这有助于



Hope this helps


这篇关于警报消息显示是和否的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 21:18